commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Heaberlin <>
Subject Re: about connection
Date Thu, 02 Dec 2004 20:55:06 GMT
This would vary by the jdbc driver, correct?  I ask this because we
read the wiki comment regarding the necessity of the validation query
and since we use DB2Connect Enterprise, we have all but abandoned
usage of validation query in our applications.

>From the wiki:

Q: Without using validation of connections (testOnBorrow = false,
testOnReturn = false, timeBetweenEvictionRunsMillis = -1) and after
shutdown and restarting the database again, it looks like the pool is
cleaning its old connections by itself. So it turns out that we always
have valid connections. How can you explain this and when is explicit
validation necessary?

A: During the connection activation (when borrowing a connection) the
setAutoCommit and other connection init methods are called. If one of
these methods throws a SQLException then the connection is also
considered broken and removed from the pool.

So if you are using one of the "default*" properties and the JDBC
driver correctly reports the SQLExceptions on the "set*" methods then
you don't need an extra validationQuery.

Did I misunderstand?

-Scott Heaberlin

On Thu, 2 Dec 2004 12:26:12 -0800, Craig McClanahan <> wrote:
> One simple approach is to set the "validationQuery" property to an SQL
> statement that does a simple select or something.  If this is set,
> DBCP will ensure that this query works successfully before handing you
> back the connection.  If the database has timed out the connection
> while it was sitting in the pool, the query will fail, and DBCP will
> close this connection and go grab another one (creating a new one if
> needed).
> Craig

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message