ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Devine, James" <james.dev...@fmr.com>
Subject RE: com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Statement is closed.
Date Wed, 18 Jun 2008 19:49:49 GMT
I found that you can specify statementCachingEnabled="false" in your
sqlMapConfig.xml.  

Unfortunately, it took me 2 days to figure this out because this is not
explained in the documentation:
http://svn.apache.org/repos/asf/ibatis/trunk/java/docs/en/iBATIS-SqlMaps
-2_en.pdf

> _____________________________________________ 
> From: 	Devine, James  
> Sent:	Wednesday, June 18, 2008 3:02 PM
> To:	'user-java@ibatis.apache.org'
> Subject:	com.ibm.websphere.ce.cm.ObjectClosedException:
> DSRA9110E: Statement is closed.
> 
> Hello,
> I am running into some issues with executing multiple iBatis calls.
> This only happens when I use a JNDI datasource (connection pooling) as
> simple JDBC datasources create a new connection each time.
> 
> The cs.execute() call is failing on the second call with exception:
> com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Statement is
> closed
> 
> Here is what I see...
> 
> The first time prepareCall is called, it executes this code to create
> the CallableStatement :
>       	CallableStatement cs = conn.prepareCall(sql);
>       	session.putPreparedStatement(delegate, sql, cs);
>       	return cs;
> 
> The second time, the session has the prepared statement, so it just
> returns it from the session:
> 	return (CallableStatement) session.getPreparedStatement((sql));
> 
> However, when this cached callable statement is used, I get the
> DSRA9110E (statement is closed) exception.
> 
> I am not using iBatis transaction management.  Instead, I have a
> spring configured interceptor that performs very basic transaction
> management (this is required due to Sybase unchained mode). 
> 
> The interceptor closes the connection, which returns the connection to
> the pool.  It seems logical that the statement may be closed as well,
> but I must be missing something.
> 
> *	Is there a way to force the call to be prepared each time?
> *	Is that the right solution?
> 
> Thanks in advance,
> JD
> 
> SqlExecutor.executeQueryProcedure()...
> 
>   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;
>     setupResultObjectFactory(request);
>     try {
>       errorContext.setMoreInfo("Check the SQL Statement (preparation
> failed).");
>       Integer rsType = request.getStatement().getResultSetType();
>       if (rsType != null) {
>         cs = prepareCall(request.getSession(), conn, sql, rsType);
>       } else {
>         cs = prepareCall(request.getSession(), conn, sql);
>       }
>       setStatementTimeout(request.getStatement(), cs);
>       Integer fetchSize = request.getStatement().getFetchSize();
>       if (fetchSize != null) {
>         cs.setFetchSize(fetchSize.intValue());
>       }
>       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).");
>       cs.execute(); // fails 2nd time (once cs is 'cached')
>       errorContext.setMoreInfo("Check the results (failed to retrieve
> results).");
> 
>       // Begin ResultSet Handling
>       rs = handleMultipleResults(cs, request, skipResults, maxResults,
> callback);
>       // End ResultSet Handling
>       errorContext.setMoreInfo("Check the output parameters (retrieval
> of output parameters failed).");
>       retrieveOutputParameters(request, cs, mappings, parameters,
> callback);
> 
>     } finally {
>       try {
>         closeResultSet(rs);
>       } finally {
>         closeStatement(request.getSession(), cs);
>       }
>     }
>   }

Mime
View raw message