• 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

Retrieving Results from Oracle

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having an OutOfMemory exception being thrown because the Vector cannot store all the information that I am retrieving.
Here's what is known:
There are 99,000 rows being returned with 8 columns of data being retrieved from the database.
The memory appears to be jumping quite rapidly if I try to retrieve the 99,000 rows of results. Is there any possible way I can minimize the memory usage and still retrieve all the results?
Any suggestions? Here is the code below which does the retrieval of information:
</pre>
public Vector getRowInfo(ResultSetMetaData rsmd, ResultSet rs)
throws SQLException
{
Vector vRow = new Vector();
Vector vRowElements = new Vector();
while(rs.next())
{
vRowElements.clear();
for(int i = 1; i <= rsmd.getColumnCount(); i++)
{
vRowElements.addElement(rs.getString(i));
}
vRow.addElement(vRowElements);
}
return vRow;
}
</pre>
Thanks
 
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
http://java.sun.com/j2se/1.3/docs/api/java/util/ArrayList.html
using an arraylist is the same as a vector except it is not synchronized which will save you some overhead. If you are retrieving 99000 rows and 8 columns per row, I think you need to get more memory! Do you need all 99000 rows at once in your vector?
Jamie
 
Rehan Malik
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I just found a better way of handling what I needed to do.
I was using a Vector to hold all the information and then pulling information from the same vector and gonna throw all the data into a JTable. Ill just throw it directly into the JTable instead of putting it into the vector over and over.
Thanks neways.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic