This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Execute Batch(OutOfMemoryError)  RSS feed

 
Ravindra Deopurkar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am executing an rs.executeBatch() which has 200000 statements in it...
During execution it throws java.lang.OutOfMemory Exception.

How can i avoid this...

Thanks
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way is to increase the heap memory. But trying to batch 200000 queries at one go, looks too much. Probably you should consider splitting up into smaller sizes.
For example, the following code snippet will batch upto 100 queries at a time.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!