JDBC ResultSet out of memory problem with Scrollable one
326154Jun 14 2006 — edited Jun 15 2006Hey guys,
I'm facing the following problem when accessing an Oracle 10g database over oracle jdbc driver 1.4.
I need to access the rows of a resultset (millions of rows) at least twice. Forward only doesn't need much memory - but I can't do a rs.beforeFirst()
Switching to ResultSet.TYPE_SCROLL_SENSITIVE gives me always an java.lang.OutOfMemoryError: Java heap space exception after rs.next() and I can see the used memory constantly increasing.
Here is my test code:
conn = DriverManager.getConnection
("jdbc:oracle:thin:@host:1521:ORCL", "user", "pass");
Statement my_stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet result = my_stmt.executeQuery("select * from stats_big");
System.out.println("Query back :)");
while(result.next()) { //here happens the error after 200 000 rows
//make statistics
}
//ask user what to do
result.beforeFirst();
while(result.next()) {
//apply function and deliver new values
}
conn.close();
Is the implementation caching all the already read rows in memory?
Any help would be great,
Alex