NullPointer exception during call of oracle stored procedure with REF CURSOR as output parameter --------------------------------------------------------------------------------------------------
Key: IBATIS-153 URL: http://issues.apache.org/jira/browse/IBATIS-153 Project: iBatis for Java Type: Bug Components: SQL Maps Versions: 2.1.0 Environment: Oracle 9. Reporter: ppz4j the invocation of an oracle stored procedura with REF CURSOR as output parameter raises a NullPointerException. The procedure's signature is : PROCEDURE test ( out_cur OUT my_cur, out_err_code OUT NUMBER, out_err_text OUT VARCHAR2 ) where TYPE my_cur IS REF CURSOR; and ibatis configuration is : <parameterMap id="params" class="map"> <parameter property="Out_Cur" jdbcType="ORACLECURSOR" mode="OUT"/> <parameter property="out_err_code" jdbcType="INTEGER" mode="OUT"/> <parameter property="out_err_text" jdbcType="VARCHAR" mode="OUT"/> </parameterMap> <resultMap id="result" class="it.app.test.Stock"> <result property="idInstrument" column="id_instrument"/> <result property="shortName" column="shortname"/> <result property="refPrice" column="refprice"/> </resultMap> <procedure id="getOptions" resultMap="result" parameterMap="params"> { call OPT_USER.TEST.TEST_CURSOR(?,?,?) } </procedure> the exception stack trace is: Caused by: java.lang.NullPointerException at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:352) at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:291) at com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:105) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78) at it.imiweb.app.data.DataModelTest.testOptions(DataModelTest.java:295) at it.imiweb.app.data.DataModelTest.main(DataModelTest.java:445) Looking inside the code it seems that the problem is due to the invocation of the follow instruction: rs = cs.getResultSet() in method executeQueryProcedure of SQLExcecutor class that returns a null value instead of the resultset as the stored procedure output. To successfully invoke the procedure i have modified the code as follow: public void executeQueryProcedure(RequestScope request, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) ... ... cs.execute(); //this method returns always null //rs = cs.getResultSet(); //with this code is possible to get the resultset even if the procedure returns more than one output parameter retrieveOutputParameters(cs, mappings, parameters); for ( int ii = 0; ii < parameters.length; ii++ ) { if ( parameters[ii] instanceof ResultSet ) { rs = ( ResultSet ) parameters[ii]; break; } } //end added code errorContext.setMoreInfo("Check the results (failed to retrieve results)."); handleResults(request, rs, skipResults, maxResults, callback); errorContext.setMoreInfo("Check the output parameters (retrieval of output parameters failed)."); //commented because it's already invoked and another call will throw an exception //retrieveOutputParameters(cs, mappings, parameters); ... ... } The driver jdbc is : Manifest-Version: 1.0 Specification-Title: "Oracle JDBC driver classes for use with JDK1.4" Specification-Version: "Oracle JDBC Driver version - 9.0.2.0.0" Specification-Vendor: "Oracle Corporation" . Implementation-Title: "ojdbc14.jar" Implementation-Version: "Oracle JDBC Driver version - 9.0.2.0.0" Implementation-Vendor: "Oracle Corporation" Implementation-Time: "Tue Apr 6 01:10:57 2004" Can you help me, please ? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira