This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Execute Batch(OutOfMemoryError) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Execute Batch(OutOfMemoryError)" Watch "Execute Batch(OutOfMemoryError)" New topic

Execute Batch(OutOfMemoryError)

Ravindra Deopurkar

Joined: Oct 19, 2005
Posts: 2
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...

Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
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.

Quaerendo Invenietis
I agree. Here's the link:
subject: Execute Batch(OutOfMemoryError)
It's not a secret anymore!