zoukankan      html  css  js  c++  java
  • jdbc调用存储过程oracle版 返回游标

    1.创建

    复制代码
    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 /
    复制代码

    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    }
  • 相关阅读:
    html 简介
    MySQL事务等了解知识
    MySQL—navicat&&练习&&pymysql
    MySQL查询表(一)
    作业
    MySQL约束&&表关系
    mysql数据类型
    初识mysql
    dll 原理解析
    又过了一天
  • 原文地址:https://www.cnblogs.com/huzi007/p/2874499.html
Copyright © 2011-2022 走看看