Monday, May 05, 2008

ORA-01000: maximum open cursors exceeded

Assum that you are looping through your result set.

If you get the "ORA-01000: maximum open cursors exceeded" error in java class, please check the following.

1. You should be having only one statemens object using connection(either statement, prepared statement or callable statement) and only one connection.

2. To make only single object for statements you can use the following check point before creating a new statements. It could be for any statements.
The below example is for prepared statement.
if(oPreparedStatement == null)
{
oPreparedStatement = oConn.getPreparedStatement(sPersonIdentifierQuery);
}

3. In your finally block don't forget to close the connection, statements and make them null. By following thies way you can get rid of the "ORA-01000: maximum open cursors exceeded exception".

4.The use of prepared statement is to compile the sql query and use it asmany time as you want, no need to prepare the statement again and again.

No comments:

Post a Comment