File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Retrieving Results from Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Retrieving Results from Oracle" Watch "Retrieving Results from Oracle" New topic
Author

Retrieving Results from Oracle

Rehan Malik
Ranch Hand

Joined: Jul 09, 2001
Posts: 76
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


Rehan Malik
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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

Joined: Jul 09, 2001
Posts: 76
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving Results from Oracle