I found this recently.
Connection conn = ...;
DatabaseMetaData dbMeta = conn.getMetaData() ;
for(int i = 0; i < 50; i++){
ResultSet tableNames = dbMeta.getTables(null,null,"%",null);
System.out.println("Opened cursor number: " +
getOpenedCursorsNum(conn));
tableNames.close();
}
Notice the last line in the for loop. If I dont use this line, my
connection to Oracle database will run out of cursor finally, by
default, I have only 50 cursors.
According JAVA API, any statement and associated resource will be
release when the statement is executed again. I think
oracle.jdbc.driver.OracleDatabaseMetaData should also use some kind of
statement, most probably a PreparedStatement for this purpose. Why the
cursor is not closed?
Does anybody know if this a bug or they have some other important
concerns?
Best wishes,
zhigang,