commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz" <phil.ste...@gmail.com>
Subject Re: DBCP 1.2.2: Test on Borrow not Working
Date Thu, 22 Nov 2007 15:57:12 GMT
On Nov 21, 2007 9:32 AM, Scott Dudley <scott@telesoft.com> wrote:
>
> I've implemented a pool using the BasicDataSource and just discovered
> that the test on borrow validation SQL isn't working.  I'm not at all
> familiar with either commons logging or log4j and can't for the life of
> me figure out how to turn on debugging for this jar.

Unfortunately, there is no debug logging included with released
versions of DBCP.
>
> Code snippet as follows:
>
>     BasicDataSource dataSource = new BasicDataSource();
>
>     dataSource.setUsername(username);
>     dataSource.setPassword(password);
>     dataSource.setUrl(url);
>     dataSource.setInitialSize(initialSize);
>     dataSource.setMinIdle(initialSize);
>     dataSource.setMaxActive(maxSize);
>     dataSource.setValidationQuery("select 1 from dual");
>     dataSource.setTestOnBorrow(true);
>
>     ...
>
>     Connection con = dataSource.getConnection();
>
> If I first initialize the pool, get a connection, and then restart my
> database - a subsequent call to dataSource.getConnection() returns a bad
> connection that has not passed the validation query.  I verified this by
> manually executing the same statement on the connection and it throws a
> SQLException with "broken pipe" or "cannot read from socket" error
> depending on Oracle version.
>

Are you sure this is not a timing issue - i.e. are you sure it is not
possible that the getConnection that retrieves the connection is not
being executed before / while the db is being cycled?

Phil

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


Mime
View raw message