You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Phil Steitz <ph...@gmail.com> on 2007/09/06 22:13:15 UTC

Re: DBCP - behavior of dbcp when db is restarted

On 9/5/07, Wm.A.Stafford <st...@marine.rutgers.edu> wrote:
> We are using DBCP in a refactored web application that, in the past,
> used a locally written connection pool.  This original pool always
> checked a connection object to see if it was NULL before handing it
> out.  I was told that this was because the  DB was unstable at one point
> and the pool was handing out connections that were null after a db restart.
>
> I would like to know if this is an issue with DBCP.  I can't image that
> it would be, this seems like a common enough situation.  However, the
> higher ups are concerned that we have subtracted functionality by using
> DBCP.

DBCP can be configured to validate connections before lending them
them to clients. Its method of doing so is to execute a "validation
query" that must return at least one row to succeed.  There is
currently no built-in facility for testing for null or bad connections
other than this.  Assuming you are using BasicDataSource, the relevant
configuration parameters to ensure connections are tested before being
returned to clients are testOnBorrow and validationQuery (see
http://commons.apache.org/dbcp/configuration.html).  You can also
force connections to be tested when they are returned to the pool by
setting testOnReturn to true.

DBCP's abilities to handle network and database failure / recovery
scenarios are primitive - validation as above is pretty much all that
exists and validation queries can hang in the event of a network
failure (see http://issues.apache.org/jira/browse/DBCP-226).  Patches,
suggestions for improvement are welcome.

Phil

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org