tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: [jdbc-pool] Transaction left open by the connection validation mechanism ?
Date Fri, 04 Jan 2013 21:38:21 GMT
Hash: SHA256


On 1/4/13 4:26 PM, Pid wrote:
> On 04/01/2013 20:34, Christopher Schultz wrote:
>> On 1/3/13 12:49 PM, Davoust, Pascal wrote:
>>> I then had a look at the corresponding code into the tomcat
>>> jdbc pool (source 7.0.34), and more specifically in class 
>>> org.apache.tomcat.jdbc.pool.PooledConnection, method public 
>>> boolean validate(int validateAction,String sql) at line 452 
>>> (excerpt below):
>>> Statement stmt = null; try { stmt =
>>> connection.createStatement(); stmt.execute(query);
>>> stmt.close(); this.lastValidated = now; return true; } catch
>>> (Exception ex) { if 
>>> (getPoolProperties().getLogValidationErrors()) { log.warn("SQL 
>>> Validation error", ex); } else if (log.isDebugEnabled()) { 
>>> log.debug("Unable to validate object:",ex); } if (stmt!=null)
>>> try { stmt.close();} catch (Exception ignore2){/*NOOP*/} }
>>> return false;
>> You (may) have a resource leak: you are not closing your
>> statement in the case of an exception. You need a 'finally'
>> block.
> I think Pascal is saying that the above snippet is in the Tomcat
> JDBC code, not his.

Whoops, I think you're right. That's a minor bug, but definitely one
that should be fixed IMO.

Also, if the validation query succeeds and the connection is in
auto-commit mode, we may want to issue a rollback. I wouldn't want to
do that without any additional configuration, though, because it would
needlessly send ROLLBACK queries in many cases (such as other
databases - MySQL doesn't get upset when I tried a simple, similar
test - or when you don't intend to change the transaction isolation
level, etc.).

Perhaps a configuration directive like rollBackAfterValidationQuery or

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with undefined -


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

View raw message