3 messages in com.mysql.lists.javaRe: ResultSet closed unexpectedly
FromSent OnAttachments
Mike Yawn03 Nov 2005 19:36 
Jeff Mathis04 Nov 2005 06:53 
Mike Yawn04 Nov 2005 08:08 
Subject:Re: ResultSet closed unexpectedly
From:Jeff Mathis (jmat@predict.com)
Date:11/04/2005 06:53:28 AM
List:com.mysql.lists.java

is your connection timing out?

On Nov 3, 2005, at 8:36 PM, Mike Yawn wrote:

I have a problem where a ResultSet is being closed unexpectedly.

Most of the postings I've seen that reference this problem seem to come down to a case of reusing a Statement. We aren't doing that.

Here's what we are doing: - Application is single threaded, so obtains a database Connection during startup which is cached and used for the life of the app. - A whole bunch of PreparedStatements are lazily initialized at various times during the life of the app. Each PreparedStatement is initialized with a single SQL query or update, and will only be used to execute that SQL statement (with parameter value changes). - A PreparedStatement query is executed which returns us a ResultSet. - While iterating over the ResultSet, we will call another method which will cause another PreparedStatement's query to be executed - it is definitely not the same PreparedStatement as the one we're iterating over, and accesses a different table in the same database - Once we do execute the query on the second PreparedStatement, as soon as we come back and try to retrieve another field from the original ResultSet, an error is thrown saying the ResultSet is closed.

The way I read things, it appears this should be legal (multiple ResultSets are OK as long as they are for different PreparedStatements, even if they are on the same Connection). Am I wrong? Is there some other caveat that applies?

Thanks,