import java.sql. * ; public class Test ... { /** *//** * @param args */ public static void main(String[] args) ...{ try...{ System.out.println("------begin------"); Class.forName("oracle.jdbc.driver.OracleDriver"); String str="jdbc:oracle:thin:scott/tiger@localhost:1521:master"; Connection conn=DriverManager.getConnection(str); //插入数据 /**//* CallableStatement call=conn.prepareCall("{call user_insert(?,?,?,?,?)}"); call.setString(1, "accp"); call.setString(2, "国贸"); call.setString(3, "84385734"); call.setString(4, "accp@126.com"); call.registerOutParameter(5,Types.INTEGER); call.execute(); System.out.println(call.getInt(5)); */ //查询数据 /**//*数据库脚本 --包规范 create or replace package user_pag is Type myCursor is ref cursor; procedure getUsers(my out myCursor); end user_pag; / --包主体 create or replace package body user_pag is procedure getUsers(my out myCursor) as begin open my for select * from users; end getUsers; end user_pag; / */ CallableStatement cs=conn.prepareCall("{call user_pag.getUsers(?)}"); cs.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR); cs.execute(); ResultSet rs=(ResultSet)cs.getObject(1); while(rs.next())...{ System.out.println(rs.getInt(1)+"---"+rs.getString(2)+"---"+rs.getString(3)+"---"+rs.getString(4)+"---"+rs.getString(5)); } rs.close(); System.out.println("------end------"); }catch(Exception ex)...{ ex.printStackTrace(); } }}