我有一個存儲過程返回SYS_REFCURSOR,我試圖獲取使用JDBC從Java光標。錯誤使用取出由PLSQL SYS光標時,JDBC
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;
/
Java代碼
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));
}
當我執行我正在以下execeptions
java.lang.NullPointerException at callablestatement.execute();
和
Non supported SQL92 token at position: 3: cal
0以上
AT在'callablestatement.execute什麼線空 – shareef
();'謝謝 – user75ponic
看看了'prepareCall'線。應該是'調用my_proc'而不是'cal my_proc'? –