Hi guys.
The problem I've faced with is the OutOfMemory error while I'm tryig to get a huge number of records from the db.
The following code is executed:
Code:
getSession().doWork(new Work() {
execute(Connection conn) {
Statement st = null;
ResultSet rs = null;
try {
st = conn.createStatement();
st.setMaxRows(40000);
st.setFetchSize(2000);
rs = st.executeQuery(someSqlString);
while (rs.next) {
// parse resultset
} finally {
if (rs != null) rs.close();
if (st != null) st.close();
}
}
}
And that's it. What should I say is that I get result in 2-3 seconds, that is pretty fast I think. But after some time of querying I've got OutOfMemory. My guessing is that I should also close the connection, but isn't it handled by Hibernate?
What's your thoughts, guys? Many thanks in advance.