my dog learned polymorphism*
The moose likes JDBC and the fly likes java.lang.OutOfMemory error while fetching data from large tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.lang.OutOfMemory error while fetching data from large tables" Watch "java.lang.OutOfMemory error while fetching data from large tables" New topic
Author

java.lang.OutOfMemory error while fetching data from large tables

chaitanya Komaravalli
Greenhorn

Joined: Sep 12, 2003
Posts: 1
Hi,
i am trying to fetch data using "executeQuery()" into a ResultSet from the database. But since the data in that table is large, i am recieving "java.lang.OutOfMemory" Error. So, to resolve that, i have used "setMaxRows()" for my statement object. This resolved the error but i don't recieve the entire data. If i call "executeQuery()" again, i recieve the same data. I don't even know a filtering criterion where by i can filter the data for each "executeQuery()"..
How can i resolve this problem

Thanx in advance
--Chaitanya
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
If the table is so large - what do you expect your program to do with it? What is the purpose of this app?
Pravin Panicker
Ranch Hand

Joined: Oct 05, 2000
Posts: 62
You are selecting huge amount of data at one go. So the exception is expected. But will you be using all of them?
you could resort to some sort of pagination , if your application permits, and fetch
fewer records as and when needed.


Pravin R Panicker<br />SCJP,SCWCD
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by Pravin Panicker:
You are selecting huge amount of data at one go. So the exception is expected. But will you be using all of them?
you could resort to some sort of pagination , if your application permits, and fetch
fewer records as and when needed.

I iterate through hundreds of thousands of rows without any problems, even when my code was very...ummm...inefficient ( new to programming ). Iterating through a resultset itself is not grounds for getting out of memory errors. The problem is when you accidentally hold that record in memory. You can avoid holding the data in memory by using a NON-scrollable resultset, not adding each row to a collection, and not using a rowset. If you are holding the records in memory ( intentional or unintentional ) then you can expect at some point for your computer or JVM to run out of memory.
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.OutOfMemory error while fetching data from large tables
 
Similar Threads
java.lang.OutOfMemory
java.lang.outofmemory
java.lang.outOfMemory in oc4j
java.lang.outOfMemory
java.lang.OutOfMemory error