MySQL Forums
Forum List  »  Connector/JDBC and Java

Tomcat, JDBC, MySQL and OutOfMemory issue
Posted by: Raj
Date: January 11, 2005 06:11AM

Hi,

I am using MySQL 4.1.7 on W2K with mysql-connector-java-3.0.14-production-bin.jar as the JDBC Driver. Following is the snippet that I am using to execute a Select statement. It may result in a large no. of rows (50000+). However, while rotating the ResultSet, I am constantly getting a java.lang.OutOfMemory exception. For small number of rows, it works fine. The machine is having 512 MB RAM. The sql is fired by a Servlet hosted on Tomcat 5.0.19 (deployed on same machine) with 128MB min heap size and 256MB max heap size.
<code>
int i = 0;
lcon = PoolUtility.getConnection();
lpst = lconDM.prepareStatement(lstrSql, ResultSet.FETCH_FORWARD, ResultSet.CONCUR_READ_ONLY);

mLog.info(lstrSql);

lpst.setFetchSize(Integer.MIN_VALUE);
lrst = lpstDM.executeQuery();

mLog.info("Reading Data");
while (lrst.next()){
++i;
if(i%1000 == 0){
Thread.yield();
}
...
}
</code>

The sql is executed and when ResultSet is rotated, in between it just goes out of memory. Does it mean a Tomcat configuration issue?

I have even tried removing the ResultSet.FETCH_FORWARD, ResultSet.CONCUR_READ_ONLY parameters and lpst.setFetchSize(Integer.MIN_VALUE), but to no avail.

Plz suggest what could be wrong in the approach. Would appreciate any new approach too.

Regards,
Raj

Options: ReplyQuote


Subject
Written By
Posted
Tomcat, JDBC, MySQL and OutOfMemory issue
Raj
January 11, 2005 06:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.