• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC

 
Aruna Kolla
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic