日期:2014-05-17  浏览次数:20813 次

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();