> I do several statements within a transaction sometimes, so really need the
> same connection for a number of statements.

In J2EE, this can be achieved using javax.transaction.UserTransaction
along with a java.sql.DataSource. In that case, transactions can be
distributed and they're no longer bound to the Connection object. I'm
not sure how this works with other connection pools, though.

> Closing the factory was more meant to be aimed at making sure that there
> isn't an illegal reference to a connection which could be being used
> elsewhere.

Yes. Unfortunately, that's not possible, unless you serialise your
records - in case of which the underlying transient Connection is
"lost"

> I guess it really makes more sense to close the underlying connection rather
> than the factory. (Probably a bad idea to re-use connections without some
> kind of pooling to return them to some consistent state anyway!)

That depends on your system architecture...

Cheers
Lukas

Reply via email to