[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-java
Subject:    Re: ResultSet closed unexpectedly
From:       Mike Yawn <mike () theYawns ! com>
Date:       2005-11-04 16:08:35
Message-ID: 20051104080835.BUV09617 () mp1 ! mc ! surewest ! net
[Download RAW message or body]


Well, it looks like the same PreparedStatement is being executed after all.  Nothing \
to see here, move along.

When the second, supposedly unrelated, query is executed, an event is being fired, \
and it now looks like the PropertyChangeListener for that event will (eventually) \
recurse back into the same query that we initially executed (and are still processing \
the ResultSet for).

I'm going to have to work with other team members to understand how we might adapt \
our event/listener architecture to avoid this, but at this point it certainly appears \
that our code is doing exactly what I said it didn't -- executing the same \
PreparedStatement before the ResultSet of the first one has been completely \
processed.

Oops :-(.

Mike

---- Original message ----
> Date: Fri, 4 Nov 2005 07:53:50 -0700
> From: Jeff Mathis <jmathis@predict.com>  
> Subject: Re: ResultSet closed unexpectedly  
> To: Mike Yawn <mike@theYawns.com>
> Cc: java@lists.mysql.com
> 
> 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,
> > 
> > Mike Yawn
> > mike@theYawns.com
> > 
> > 
> > 
> > -- 
> > MySQL Java Mailing List
> > For list archives: http://lists.mysql.com/java
> > To unsubscribe:    http://lists.mysql.com/java? 
> > unsub=jmathis@predict.com
> > 
> > 
> 

-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/java?unsub=mysql-java@progressive-comp.com


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic