We use Spring SimpleJdbcCall to call stored procedures in Oracle that return cursors. It seems that SimpleJdbcCall does not close the cursors, and after a while the maximum open cursors are exceeded.
ORA-01000: maximum open cursors exceeded ; nested exception is java.sql.SQLException: ORA-01000: maximum open cursors exceeded spring
There are several other people on the forums who have experienced this, but do not seem to have received answers. It looks like a bug in spring oracle support.
This error is critical and may affect our future use of Spring JDBC.
Does anyone encounter a fix โ either tracking a problem with Spring code, or finding a workaround that avoids the problem?
We are using Spring 2.5.6.
Here is a new version of the code using SimpleJdbcCall that does not seem to correctly close the result set that proc returns with the cursor:
... SimpleJdbcCall call = new SimpleJdbcCall(dataSource); Map params = new HashMap(); params.put("remote_user", session.getAttribute("cas_username") ); Map result = call .withSchemaName("urs") .withCatalogName("ursWeb") .withProcedureName("get_roles") .returningResultSet("rolesCur", new au.edu.une.common.util.ParameterizedMapRowMapper() ) .execute(params); List roles = (List)result.get("rolesCur")
An older version of code that does not use Spring JDBC does not have this problem:
oracleConnection = dataSource.getConnection(); callable = oracleConnection.prepareCall( "{ call urs.ursweb.get_roles(?, ?) }" ); callable.setString(1, (String)session.getAttribute("cas_username")); callable.registerOutParameter (2, oracle.jdbc.OracleTypes.CURSOR); callable.execute(); ResultSet rset = (ResultSet)callable.getObject(2); ... do stuff with the result set if (rset != null) rset.close();
It appears that Spring JDBC does NOT call rset.close (). If I comment on this line in the old code, then after load testing we will get the same database error.
java spring oracle jdbc
Brendan heywood
source share