为了账号安全,请及时绑定邮箱和手机立即绑定

java调用返回一个光标的存储过程出错?

java调用返回一个光标的存储过程出错?

慕神8329975 2016-07-18 11:12:26
为什么我取不出结果,就是控制台上没有打印任何东西,也没有出什么错。代码贴上:create or replace package mypackage as    type empcursor is ref cursor;    procedure queryemplist(dno in number,emplist out empcursor);end mypackage;create or replace package body mypackage as    procedure queryemplist(dno in number,emplist out empcursor) asbegin    open emplist for select * from emp where empno=dno;    end queryemplist; end mypackage;--------------------------------------------------------------------------------------------public static void main(String[] args) {        Connection conn = null;        CallableStatement call = null;        ResultSet rs = null;        try {            String sql = "{call MYPACKAGE.queryemplist(?,?)}";            conn  = JDBCUtil.getConn();            call = conn.prepareCall(sql);            call.setInt(1, 20);            call.registerOutParameter(2,OracleTypes.CURSOR);            call.execute();            rs = ((OracleCallableStatement)call).getCursor(2);            //rs = (ResultSet) call.getObject(2);            while(rs.next()){                int deptno = rs.getInt("deptno");                String name = rs.getString("ename");                String job = rs.getString("job");                double salary = rs.getDouble("sal");                System.out.println(deptno+"\t"+name+"\t"+job+"\t"+salary);            }        } catch (Exception e) {            e.printStackTrace();        }    }
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 1419 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信