tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: problems at
Date Tue, 01 Jun 2010 14:14:26 GMT
Hash: SHA1

Yucca Nel,

On 5/30/2010 1:53 PM, Yucca Nel wrote:
> Ok I need to keep connection open to avoid exceeption but have found
> this is deprecated ....
> autoReconnect=true
> can someone provide up to date strategy for dealing with this?

Don't use autoReconnect as a parameter to the JDBC driver. Instead, use
the "validationQuery" on the connection pool to have the pool verify
that the connection is still valid. MySQL Connector/J even supports a
"ping" query that can gracefully fall-back to driver versions that don't
support it.

I highly recommend that you:

1. Use a Tomcat-configured DataSource
2. Use a DataSourceRealm coupled with #1
3. Tell Hibernate to use #1

That way, all your db configuration is in one place.

Add this parameter to your DataSource configuration (it configures the
connection pool):

validationQuery="/* ping */ SELECT 1"

This will cause the connection pool to execute that query every time a
connection is requested from the pool, just to verify that it's properly
connected. Your web application should never get a dead connection and
therefore shouldn't have to deal with that situation.

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


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

View raw message