[
http://issues.apache.org/jira/browse/IBATIS-53?page=comments#action_12313497 ]
David Winterbottom commented on IBATIS-53:
------------------------------------------
Running the suplied code (number 6) with log4j-1.2.9 on the class path gives me
a NullPointerException.
Am I doing something wrong ?
(see IBATIS-152)
DEBUG [main] - Created connection 3235124.
DEBUG [main] - {conn-100000} Connection
DEBUG [main] - {pstm-100001} PreparedStatement: { ? = call
mis_extract.mgr_case_temp.FindCases }
DEBUG [main] - {pstm-100001} Parameters: []
DEBUG [main] - {pstm-100001} Types: []
DEBUG [main] - {rset-100002} ResultSet
DEBUG [main] - Returned connection 3235124 to pool.
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/kinnect/mis/datamodel/sql/CaseToExtract.xml.
--- The error occurred while applying a parameter map.
--- Check the output.
--- Check the output parameters (retrieval of output parameters failed).
--- Cause: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:184)
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:100)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:97)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:69)
at com.kinnect.mis.MISExtract.readCasesToExtract(MISExtract.java:233)
at com.kinnect.mis.MISExtract.main(MISExtract.java:64)
Caused by:
java.lang.NullPointerException
at java.lang.reflect.Method.invoke(Native Method)
at
com.ibatis.common.jdbc.logging.ResultSetLogProxy.invoke(ResultSetLogProxy.java:47)
at $Proxy2.close(Unknown Source)
at
com.ibatis.sqlmap.engine.execution.SqlExecutor.closeResultSet(SqlExecutor.java:392)
at
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:298)
at
com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34)
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:169)
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:100)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:97)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:69)
at com.kinnect.mis.MISExtract.readCasesToExtract(MISExtract.java:233)
at com.kinnect.mis.MISExtract.main(MISExtract.java:64)
> Support for oracle cursors as resultsets
> ----------------------------------------
>
> Key: IBATIS-53
> URL: http://issues.apache.org/jira/browse/IBATIS-53
> Project: iBatis for Java
> Type: New Feature
> Components: SQL Maps
> Reporter: Ken Katsma
> Priority: Minor
> Fix For: 2.1.0
> Attachments: SqlExecutor.java, SqlExecutor.java, SqlExecutor.java,
> SqlExecutor.java, showcase.txt, showcase_storedprocedure.txt,
> showcase_storedprocedure1.txt
>
> iBatis doesn't currently support result sets from functions in Oracle. A
> modification to SQLExecutor as detailed below can add the necessary support.
> However, it requires a hard-coded check for an Oracle driver. A better
> option would be to supply a factory for alternate SQLExecutor's for different
> dialects. This would allow for any future database specific customization as
> well.
> The code change is in SQLExecutor.executeQueryProcedure (see comments):
> public void executeQueryProcedure(RequestScope request, Connection conn,
> String sql, Object[] parameters,
> int skipResults, int maxResults,
> RowHandlerCallback callback)
> throws SQLException {
> ErrorContext errorContext = request.getErrorContext();
> errorContext.setActivity("executing query procedure");
> errorContext.setObjectId(sql);
> CallableStatement cs = null;
> ResultSet rs = null;
> try {
> errorContext.setMoreInfo("Check the SQL Statement (preparation
> failed).");
> cs = conn.prepareCall(sql);
> ParameterMap parameterMap = request.getParameterMap();
> ParameterMapping[] mappings = parameterMap.getParameterMappings();
> errorContext.setMoreInfo("Check the output parameters (register output
> parameters failed).");
> registerOutputParameters(cs, mappings);
> errorContext.setMoreInfo("Check the parameters (set parameters
> failed).");
> parameterMap.setParameters(request, cs, parameters);
> errorContext.setMoreInfo("Check the statement (update procedure
> failed).");
> // ****************************************
> // Code changes below
> // ****************************************
> if
> (conn.getMetaData().getDatabaseProductName().equalsIgnoreCase("Oracle"))
> {
> // If in oracle then execute instead of executeQuery
> boolean b = cs.execute();
> errorContext.setMoreInfo("In Oracle query mode.");
> errorContext.setMoreInfo("Check the output parameters (retrieval of
> output parameters failed).");
> // Get the output parameters first, instead of last
> retrieveOutputParameters(cs, mappings, parameters);
> // Then find the resultset and handle it
> for (int i=0;i<parameters.length;i++)
> {
> if (parameters[i] instanceof ResultSet)
> {
> rs = (ResultSet) parameters[i];
> break;
> }
> }
> errorContext.setMoreInfo("Check the results (failed to retrieve
> results).");
> handleResults(request, rs, skipResults, maxResults, callback);
> }
> //****************************************
> // Non-oracle..original code
> else
> {
>
> errorContext.setMoreInfo("In non-Oracle mode.");
> rs = cs.executeQuery();
> 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).");
> retrieveOutputParameters(cs, mappings, parameters);
> }
> } finally {
> try {
> closeResultSet(rs);
> } finally {
> closeStatement(cs);
> }
> }
> An example mapping looks like:
> <parameterMap id="clientParameters" class="map" >
> <parameter property="result" jdbcType="ORACLECURSOR" mode="OUT"/>
> <parameter property="maxRows" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN"/>
> </parameterMap>
> <procedure id="getClientListProc" resultMap="clientResult"
> parameterMap="clientParameters">
> {?= call abc.CLIENT_VIEW_PKG.client_result_list_f(?)}
> </procedure>
--
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