为什么我取不出结果,就是控制台上没有打印任何东西,也没有出什么错。
代码贴上:
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) as
begin
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();
}
}