commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: about connection
Date Thu, 02 Dec 2004 21:01:15 GMT
On Thu, 2 Dec 2004 15:55:06 -0500, Scott Heaberlin <heabdogg@gmail.com> wrote:
> 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: http://wiki.apache.org/jakarta-commons/DBCP
> 
> <quote>
> 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.
> </quote>
> 
> Did I misunderstand?

No, it's just that JDBC drivers throwing an exception on things like
setAutoCommit(), if the underlying database connection is stale, are
definitely not universal.  If you're lucky enough to be using one, you
don't need validation queries ... but the capability is still needed
by others that are not so lucky.

> -Scott Heaberlin

Craig

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


Mime
View raw message