1.创建

 

jdbc调用存储过程-oracle版 返回游标
1 create or replace procedure getLog(record_ref out sys_refcursor,inputId in log201112.id%type)
2 AS
3 begin
4 open record_ref for
5     select * from log201112 where id=inputId;
6 end getLog;
7 /
jdbc调用存储过程-oracle版 返回游标

2.调用

 

 1 String procedure="{call getLog(?,?)}";
 2   CallableStatement cstmt=conn.prepareCall(procedure);//conn为java.sql.Connection对象
 3   cstmt.registerOutParameter(1, OracleTypes.CURSOR);//oracle驱动包里的类 import oracle.jdbc.OracleTypes;
 4   cstmt.setInt(2, 2);
 5   cstmt.execute();
 6   ResultSet rs=(ResultSet)cstmt.getObject(1);
 7   while(rs.next()){
 8       String info=""+rs.getInt("ID");
 9       info+=rs.getTimestamp("CREATE_TIME");
10       System.out.println(info);
11    }

 

 

 

相关文章:

  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2021-12-28
  • 2021-08-05
  • 2021-09-07
  • 2022-01-13
相关资源
相似解决方案