Steve A Drake wrote:

> On Thu, 28 Dec 2000, Ted Husted wrote:
>
> > I'm thinking that the Action could grab a connection from the pool, and
> > generate a statement based on the bean's query string, store the result
> > in the bean's ResultSet, punch the rows we need into the collection,
> > and foward it on to the form, where the interate tag could run it
> > through the iterate tag.
>
>  So can you clone a ResultSet? The last time I looked into this I found
> that you have to maintain the Connection you used to obtain a ResultSet
> until you've finished iterating through it. If you close the connection,
> you lose the ResultSet. If you can clone a ResultSet, close the
> connection, and then later iterate the cloned ResultSet, I'd sure like to
> see how to do that.
>
>  In lieu of cloning, I store a ResultSet in another object and then pass
> this new object along by firing an event. Problem is, my formulation is
> not a generic solution. But it does have the advantage that I can return
> the connection to the pool sooner and it confines connection handling to
> one method.

One option to do this, without maintaining a Connection throughout the process,
is to copy the ResultSet data into an appropriate RowSet implementation from the
JDBC 2.0 Standard Extensions API.  In particular, several of the available
RowSet implementations are designed to be used in a "disconnected" fashion, and
then later "reconnected" to apply any updates to the underlying database.

See the relevant spec at <http://java.sun.com/products/jdbc> for more info.

Craig

Reply via email to