当前位置: 代码迷 >> Oracle开发 >> JAVA 调用存储过程报错无效索引-求解脱,该怎么解决
  详细解决方案

JAVA 调用存储过程报错无效索引-求解脱,该怎么解决

热度:92   发布时间:2016-04-24 06:48:17.0
JAVA 调用存储过程报错无效索引----求解脱
JAVA代码
CallableStatement callstatement =connection.prepareCall("{call sp_pro(?,?)}");
callstatement.setInt(1, 10);
callstatement.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR);
//得到结果姐
ResultSet rs= (ResultSet) callstatement.getObject(2);
while(rs.next()){

System.out.println(rs.getInt(1)+"用户名:"+rs.getString(2));
}
存储过程如下
create or replace procedure sp_pro18(spNo in number,p_cursor out testpackage.test_cursor) is
begin
open p_cursor for select  * from emp where deptno=spNo;
end;
eclipse报错无效索引在
ResultSet rs= (ResultSet) callstatement.getObject(2);
------解决方案--------------------
得到结果集之前,是不是应该加一个callstatement.execute();
  相关解决方案