Answer the question
In order to leave comments, you need to log in
Will jvm die or not without pagination?
PreparedStatement ps = db.preparedStatement("select * from tbl");
ResultSet rs = ps.executeQuery();
while(rs.next) {
...
process(...);
...
}
Answer the question
In order to leave comments, you need to log in
zhdbts-shnye rezaltsets read records by the cursor line by line. if you don't store what you get in memory inside your process, then the fetch size can be arbitrarily large.
It depends on what you have in the lines, what resources the host has, what garbage collector is used, how the JVM is configured, etc. etc. There are Java programs that work with terabyte heaps.
It all depends on the specific situation (which database, the driver used, the amount of data).
The last time I processed a large table, I initialized statement like this:
PreparedStatement preparedStatement = connection.prepareStatement(query,
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
preparedStatement.setFetchSize(fetchSize);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question