db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: PooledConnection being closed
Date Mon, 15 Aug 2005 11:40:37 GMT
Tony Seebregts <tonys@cibecs.com> writes:

> Hi,
> I'm writing a connection pool manager using the
> EmbeddedConnectionPoolDatasource class. The requesting object gets the
> Connection object from a PooledConnection  getConnection() , executes
> a SQL statement and then closes the Connection.
> This correctly invokes the ConnectionEventListener.close() method -
> which simply marks the pooled connection as available for reused. But
> when I try to resuse the connection originally supplied by the
> PooledConnection getConnection() method the connection is
> closed. Calling getConnection returns me a new Connection which is
> (AFAIK) not the idea.

Well, the point with pooled connections is that you use
getConnection() and close() as with ordinary connections, but the
underlying physical connection is kept open. The Connection object
returned by getConnection() is a logical connection, and you cannot
use it after it is closed. If you call getConnection() again, you will
get a new logical connection, and therefore a new Connection
object. However, the new logical connection might still use the same
physical connection.

Knut Anders

View raw message