tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: deadlock in database connection pooling?
Date Fri, 11 Dec 2009 15:53:35 GMT
Hash: SHA1


On 12/10/2009 7:43 PM, Mitch Claborn wrote:
>               poolPreparedStatements="true"
>               driverClassName="com.mysql.jdbc.Driver"
>               validationQuery="select * from operator limit 1"

FWIW, this is a non-ideal validation query:

1. It uses SELECT *, which is not particularly efficient.
2. It uses a real table, which means that real data will be selected.
3. It uses a LIMIT, which means that you know that too much data is
   going to come back.

Might I suggest:

validationQuery="/* ping */SELECT 1"

MySQL Connector/J drivers after a certain version recognize the "/* ping
*/" at the beginning of the query and will execute a low-level
connection check that does not involve a query at all! So, you get your
validation that the connection is properly connected without all that
silly work on the server.

If the version of the MySQL driver is NOT new enough, it will execute
the "SELECT 1" query which consults no tables and executed super fast.

You win both ways.

>               testWhileIdle="true"
>               testOnBorrow="false"
>               testOnReturn="false"

That's an odd configuration... why test while idle but not when the
connection is needed?

I suspect that if you set testOnBorrow="true" and testWhileIdle="false",
you will avoid your deadlock problem.

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


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

View raw message