jump to navigation

View open cursors in Java January 23, 2007

Posted by maxmil in : Java,Oracle , trackback

Been having problems with an application that doesn’t close its ResultSets and Statements, the infamous ORA-01000: maximum open cursors exceeded. Searching for the code responsable would have been a long tedious process. The code that i was interested in was contained in a big for loop.

Luckily i found that oracle (version 9i) as a view in the sys schema called v$open_cursor that contains information about the open cursors at any given moment.

Putting a query at the end of each iteration of my for loop i was able to quickly find the culprit.

The necessary query was: select sql_text from v$open_cursor where user_name = 'SOPORTETECNICO'where SOPORTETECNICO is the user that my application uses to connect to the database.

The code snippet that i used was:ResultSet rsoc = dblink.query("select sql_text from v$open_cursor where user_name = 'SOPORTETECNICO'");
while (rsoc.next()){
System.out.println(rsoc.getString("sql_text"));
}
rsoc.getStatement().close();

Comments»

no comments yet - be the first?