我有一个返回 sys_refcursor 的存储过程,我正在尝试使用 JDBC 从 java 中获取游标。
plsql存储过程
create or replace procedure my_proc(p_deptno IN number,p_emp_no IN varchar2
, p_cursor OUT SYS_REFCURSOR)
is
begin
open p_cursor FOR
select *
from emp
where deptno = p_deptno and emp_number=p_emp_no;
end proc;
/
爪哇代码
callablestatement = connection.prepareCall("{cal my_proc(?,?,?)} ");
callablestatement.setInt(1, param1);
callablestatement.setString(2, param2);
callablestatement.registerOutParameter(3, OracleTypes.CURSOR);
callablestatement.execute();
resultSet = ((OracleCallableStatement)callablestatement).getCursor(4);
while (resultSet.next()) {
<classname> = mapList(resultSet);
logger.info(resultSet.getString(1));
}
当我执行上述操作时,我收到以下异常
java.lang.NullPointerException at callablestatement.execute();
和
Non supported SQL92 token at position: 3: cal