-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Session doWork OutOfMemory
PostPosted: Wed Apr 22, 2015 2:36 pm 
Newbie

Joined: Wed Apr 22, 2015 2:16 pm
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.