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: Re. PooledConnection being closed
Date Mon, 15 Aug 2005 16:44:41 GMT
Tony Seebregts <tonys@cibecs.com> writes:

> Ok, thanks Knut - my misunderstanding.
>
> I understood the ConnectionPoolDataSource as merely facilitating
> connection pooling. If it manages the actual pooling though, is
> there any point in handling the ConnectionEvents ? Other than for
> monitoring/interest ...

The ConnectionPoolDataSource doesn't manage the connection pool. It is
just an instrument which is used by a connection pool manager. A
ConnectionPoolDataSource can create PooledConnection objects, but
since each PooledConnection can have only one open Connection object
at a time, you'll probably need more than one PooledConnection object,
and the need for a pool manager emerges.

A typical connection pool manager has a getConnection() method which
checks whether there is an unused PooledConnection in the pool. If
there is one, PooledConnection.getConnection() is called, otherwise a
new PooledConnection is created and its getConnection() is called. In
addition the manager has to make sure that the pool doesn't become too
big, that invalid PooledConnection objects are removed from the pool,
etc. That's where the ConnectionEvent handlers come into use. The
connectionClosed() method marks a PooledConnection as unused, and
removes it from the pool if the pool has become too big. The
connectionErrorOccurred() removes an invalid PooledConnection from the
pool.

-- 
Knut Anders


Mime
View raw message