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


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.
int i = 0;
lcon = PoolUtility.getConnection();
lpst = lconDM.prepareStatement(lstrSql, ResultSet.FETCH_FORWARD, ResultSet.CONCUR_READ_ONLY);


lrst = lpstDM.executeQuery();

mLog.info("Reading Data");
while (lrst.next()){
if(i%1000 == 0){

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.


Options: ReplyQuote

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

