GeeCON Prague 2014*
The moose likes JDBC and the fly likes JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC" Watch "JDBC" New topic
Author

JDBC

Aruna Kolla
Greenhorn

Joined: Jan 31, 2002
Posts: 2
Hi,
I am using Oracle 8.1.6 and accessing it through JDBC driver using Java program.
In application code, I retrieve 2.5 million records. While looping through the result set, I make three more queries to the database using prepared statements. When I run my application, I get following error
Outofmemory oracle.jdbc.ttc7.TTCItem.
I tuned JVM and set its maximum heapsize to 500 MB and ran the application again. But still I have the same problem. Any ideas how I can resolve the problem?? Is there any way to solve this problem without depending on JVM heapsize?
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

are you storing this resultset to an arrayList or Vector or something!!??? Something in your program keeps on growing without the gc able to do its job. Do you close all your subsequent resultsets? Do you keep creating new objects in the loop of 2.5 million rows?
I don't know where to start. If the code isn't too overwhelming, maybe you could post it.
Jamie
Aruna Kolla
Greenhorn

Joined: Jan 31, 2002
Posts: 2
The main loop of the code is as follows :
while(rs.next()) // 2.5 million rows loop
{
Customer custObj = new Customer();
Hashtable attr_name_values = custObj.getAttributesBuffer();
usr_id=rs.getString("usr_id").trim();
Enumeration xmlnames=primary_info_ht.keys();
while(xmlnames.hasMoreElements())
{
column_key =(String)xmlnames.nextElement();
attr_name=(String)primary_info_ht.get(column_key);
attr_value=(String)rs.getString(column_key);
if(attr_value != null)
{
attr_name_values.put(attr_name, attr_value);
}
}
1. Executes first prepared statement and closes the result set.
2. Executes second prepared statement and closes the result set.
3. Executes third prepared statement and closes the result set.
custObj.generateXML(fos); // This function uses a string buffer creates valid xml elements for a customer and prints to a file (not using dom or sax)
attr_name_values = null;
custObj = null;
}
All prepared statements are created before looping through the main result set.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"kolla",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please re-register and select a new name which meets the requirements.
Thanks.
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC