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 com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Statement is closed.
Date Wed, 18 Jun 2008 19:02:26 GMT
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

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,


  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");
    CallableStatement cs = null;
    ResultSet rs = null;
    try {
      errorContext.setMoreInfo("Check the SQL Statement (preparation
      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) {
      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
      parameterMap.setParameters(request, cs, parameters);
      errorContext.setMoreInfo("Check the statement (update procedure
      cs.execute(); // fails 2nd time (once cs is 'cached')
      errorContext.setMoreInfo("Check the results (failed to retrieve

      // Begin ResultSet Handling
      rs = handleMultipleResults(cs, request, skipResults, maxResults,
      // End ResultSet Handling
      errorContext.setMoreInfo("Check the output parameters (retrieval
of output parameters failed).");
      retrieveOutputParameters(request, cs, mappings, parameters,

    } finally {
      try {
      } finally {
        closeStatement(request.getSession(), cs);

View raw message