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);无效索引 存储过程

解决方案 »

  1.   

    得到结果集之前,是不是应该加一个callstatement.execute();
      

  2.   

    先执行的话提示
    java.sql.SQLException: 索引中丢失  IN 或 OUT 参数:: 2
      

  3.   

    不是这个错误java.sql.SQLException: ORA-06550: 第 1 行, 第 7 列: 
    PLS-00201: 必须声明标识符 'SP_PRO'
    ORA-06550: 第 1 行, 第 7 列: 
    PL/SQL: Statement ignored
      

  4.   

    先传参数和注册输出参数,再执行。sp_pro表示服未声明,是不是因为你的存储过程和程序调用的名字不一致造成的、