commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodney Waldhoff <rwaldh...@apache.org>
Subject RE: DBCP tracking stale connections?
Date Mon, 09 Dec 2002 17:00:22 GMT
On Mon, 9 Dec 2002, Martin van Dijken wrote:

> > > As for testing for stale connections - there is a parameter when DBCP
> > > pools are created that allow you to specify a query to check a
> > > connections health. If the query fails  - then the connection is
> > > considered bad and DBCP will discard the connection and open a new one.
> > Right, specifically, set the validationQuery property of your
> > PoolableConnectionFactory, and set one (or more) of testOnBorrow,
> > testOnReturn or testWhileIdle to true. (The BasicDataSource
> > bundle will automatically set testOnBorrow to true when a
> > validationQuery is set.)
>
> It seems to me that whenever I use a connection with testOnBorrow==true
> then I'm actually performing 2 queries: the validation and my own query.
> This sounds particularly inefficient. TestWhileIdle sounds a lot better
> in that aspect. Can I get that running using the Tomcat JNDI interface?

BasicDataSource currently doesn't expose testWhileIdle, although if you
look at how the other props are dealt with, it wouldn't be difficult to
expose it (a small change to BasicDataSourceFactory and BasicDataSource is
all that is required).  I'd be happy to commit the patch if you test it
first.

Alternatively, you should be able to use the "jdbc2pool" support via
Tomcat's JNDI.  Grab a nightly build of dbcp (the code has been there for
a while but wasn't part of the last release) from

<http://jakarta.apache.org/builds/jakarta-commons/nightly/commons-dbcp/>

and see

<http://nagoya.apache.org/gump/javadoc/jakarta-commons/dbcp/dist/docs/api/org/apache/commons/dbcp/jdbc2pool/package-summary.html>

for details on how to set it up with JNDI.

I don't use the JNDI service personally (nor did I write this code) but
I've heard reports that it works (and none that it doesn't).



--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message