File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes outOfMemory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "outOfMemory" Watch "outOfMemory" New topic


Elizabeth Chen

Joined: Aug 09, 2001
Posts: 7
I need to query a huge database table in order to caculate data into a Vector, everytime, I execuate the sql:
select * from JobInfo startTime > t1 and endTime <= t2
The database could return more than a lot of entries if (endTime - startTime) is greater than 1 month and generate outOfMemory exception.
I used mm.mysql JDBC which doesn't support setFetchSize.
Anyone has suggestion?
Robert Brunner
Ranch Hand

Joined: Jul 18, 2001
Posts: 49
OK, if you are getting a java exception, I would suggest increasing the size of the your JVM's heap memory (Remember the JDBC driver runs in your client JVM). The details are somewhat JVM specific (RTFM), but for the SUN JDK, you would use the -X non-standard JVM features (type java -X for a listing of them). Here are the ones you want to check with.
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
Another thing you should probably keep in mind (note I know nothing about your table schema) is don't do a SELECT * as it will return everything. If you only need a few columns, it is much better to be selective and pick only the ones you need. Another option is to get a count first of the number of rows which meet your query.
I agree. Here's the link:
subject: outOfMemory
It's not a secret anymore!