• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.OutOfMemoryError: Java heap space while Executing the Query

 
Senthil Kumar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Iam trying to execute two queries which fetches lakhs of records.
** I have one Connection Object(Singleton Object).
**I have two PREPAREDSTATEMENT objects for two queries.

I get this exception when the 2ND query is getting executed.
When iam executing one query alone instead of two queries,its getting executed successfully.
So,Problem, is here.When am executing both the queries one by one, am getting this exception.

I need both the ResultSets to be used simaltaneously.so, I CANNOT
** execute the FIRST query
** Do the needfull with the FIRST ResultSet.
** execute the SECOND Query
** Do the needful with the SECOND ResultSet.


Moreover there is nothing extra in my code.Am trying to execute the Queries.Thats it.....

Can anyone Provide me a solution.?
 
Rama Krishna Ghanta
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Senthil,

Just to understand your requirement first,you get a resultset from the first query. This resultset would be the parameters for your second query for you to execute the second one.If I am write, and from the problem description you have given, your second query is causing the problems.You can try the below method.

Instead of fetching lakhs of records at once as a single resultset,you can retrieve the data from database in chunks.for example write a "for loop" and retrieve 1000 records per every loop.

Regards,
Rama Krishna.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4028
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Senthil,

There's no obvious reason you can't execute both queries at once, so please provide a more detailed description of your problem. Also, if you are getting OutOfMemory as your subject suggests, try increasing the JVM memory allocation using the appropriate JVM switches such as xmx and xms.

-Scott
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a similar problem once and it turned out to be the driver I was using.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic