• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic