Results 1 to 6 of 6

Thread: Problem "Cursor is Closed"

  1. #1
    Join Date
    May 2009
    Posts
    5

    Default Problem "Cursor is Closed"

    Hi everyone!

    I´m having a problem to call StoredProcedures with Spring.

    The problem is that sometimes the cursor return closed(correctly). There any solution to ignore the problem "Cursor is Closed"?

    Follow the exception:

    Code:
    org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call sCcApiJpConsultaExtrato(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}]; SQL state [null]; error code [0]; Cursor is closed.; nested exception is java.sql.SQLException: Cursor is closed.
    Caused by: 
    java.sql.SQLException: Cursor is closed.
    	at oracle.jdbc.driver.T4CResultSetAccessor.getCursor(T4CResultSetAccessor.java:323)
    	at oracle.jdbc.driver.ResultSetAccessor.getObject(ResultSetAccessor.java:85)
    	at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:1401)
    	at org.springframework.jdbc.core.JdbcTemplate.extractOutputParameters(JdbcTemplate.java:993)
    	at org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:927)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:883)
    	at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:915)
    	at org.springframework.jdbc.object.StoredProcedure.execute(StoredProcedure.java:113)
    	at com.eversystems.il.dao.DAOImpl.execute(DAOImpl.java:69)
    	at com.eversystems.il.handle.transaction.EV6CMessageHandler.handle(EV6CMessageHandler.java:97)
    	at com.eversystems.il.handle.transaction.EV6CMessageHandler.handle(EV6CMessageHandler.java:1)
    	at com.eversystems.il.processor.MessageProcessorImpl.process(MessageProcessorImpl.java:135)
    	at com.eversystems.il.jms.ILMessageListenerDefault.onMessage(ILMessageListenerDefault.java:35)
    	at com.ibm.mq.jms.MQMessageConsumer.receiveAsync(MQMessageConsumer.java:3032)
    	at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:412)
    	at java.lang.Thread.run(Unknown Source)

    Thank you

  2. #2
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    Looks like the problem has nothing to do with spring. Something is wrong with the database/stored procedure.

  3. #3
    Join Date
    May 2009
    Posts
    5

    Default

    Quote Originally Posted by denis.zhdanov View Post
    Looks like the problem has nothing to do with spring. Something is wrong with the database/stored procedure.
    Hi Denis, thank you for answer.

    But spring ever wait for a opened cursor?

  4. #4
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    Quote Originally Posted by hsmedrado View Post
    Hi Denis, thank you for answer.

    But spring ever wait for a opened cursor?
    Spring just performs stored procedure call and processes the result via standard jdbc api, nothing more, nothing less.

  5. #5
    Join Date
    May 2009
    Posts
    5

    Default

    Quote Originally Posted by denis.zhdanov View Post
    Spring just performs stored procedure call and processes the result via standard jdbc api, nothing more, nothing less.
    My question is if Spring verify if the cursor is open or closed... If this verification has been done by jdbc it´s ok for me.

    tks

  6. #6
    Join Date
    May 2009
    Posts
    5

    Default

    Hi for all!

    I corrected this problem...

    I extended JdbcTemplate and overrided the method

    Map extractOutputParameters(CallableStatement cs, List parameters) throws SQLException....

    And tried the problem...following the code:

    Code:
    public Map extractOutputParameters(CallableStatement cs, List parameters) throws SQLException {
    		Map returnedResults = new HashMap();
    		int sqlColIndex = 1;
    		for (int i = 0; i < parameters.size(); i++) {
    			SqlParameter param = (SqlParameter) parameters.get(i);
    			if (param instanceof SqlOutParameter) {
    				SqlOutParameter outParam = (SqlOutParameter) param;
    				if (outParam.isReturnTypeSupported()) {
    						Object out = outParam.getSqlReturnType().getTypeValue(
    								cs, sqlColIndex, outParam.getSqlType(), outParam.getTypeName());
    						returnedResults.put(outParam.getName(), out);
    					
    				}
    				else {
    					try{
    						Object out = cs.getObject(sqlColIndex);
    						if (out instanceof ResultSet) {
    							if (outParam.isResultSetSupported()) {
    								returnedResults.putAll(processResultSet((ResultSet) out, outParam));
    							}
    							else {
    								String rsName = outParam.getName();
    								SqlReturnResultSet rsParam = new SqlReturnResultSet(rsName, new ColumnMapRowMapper());
    								returnedResults.putAll(processResultSet(cs.getResultSet(), rsParam));
    								logger.info("Added default SqlReturnResultSet parameter named " + rsName);
    							}
    						}
    						else {
    							returnedResults.put(outParam.getName(), out);
    						}
    					}catch (SQLException e) {
    						log.debug(e.getMessage());
    					}
    				}
    			}
    			if (!(param.isResultsParameter())) {
    				sqlColIndex++;
    			}
    		}
    		return returnedResults;
    	}

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •