I am getting this error when I run my code
Below is the code I have used:
String sql="SELECT * FROM PERSONS WHERE PERSONJOB='ADMIN'";
Statement stmt=null;
ResultSet rs=null;
try
{
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
While(rs.next())
{
String name=rs.getString(1);
long id=rs.getLong(2);
System.out.println(name);
System.out.println(id);
}
}
catch(Exception e)
{
throw e;
}
finally
{
rs.close();
stmt.close();
}
I want to reuse the connection, so I didn't close the connection.
After I closed the ResultSet
and Statement
, I am getting the "maximum open cursors exceeded" error.
Anyone please help me to solve this error.
My guess is that the
close()
of yourResultSet
is failing, which would result in multiple open cursors and eventually hit the max configured open cursor count. Could you modify your code to:EDIT: will be good to also clean up the already opened cursors with a combination of:
or restart the DB.