Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JDBC ResultSet out of memory problem with Scrollable one

326154Jun 14 2006 — edited Jun 15 2006
Hey 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 13 2006
Added on Jun 14 2006
7 comments
2,334 views