Chris, based on what you're saying and the server.xml posted earlier in this 
thread, the following should be done?

1. Remove the JDBCRelm from the Engine node
2. Create a GlobalNamingResources Resource entry with the following:

  description="The Jar Bar user authentication"
  maxActive="10" maxIdle="3"
  validationQuery="/* ping */ SELECT 1"

This is basically what I would normally put in the context.xml file of a web 
application for an application-specific database connection.

3. Then create a DataSource Realm under the Engine node to replace

<Realm className="org.apache.catalina.realm.DataSourceRealm"

It was a little unclear to me from the documentation that I could put all of 
the resource attributes in a GlobalNamingResources Resource entry. It was also 
a little unclear to me that I could just refer to a global resource name with 
dataSourceName in the Realm.

Thanks for clearing that up.

. . . just my two cents


--- On Tue, 6/1/10, Christopher Schultz <> wrote:

> From: Christopher Schultz <>
> Subject: Re: problems at
> To: "Tomcat Users List" <>
> Date: Tuesday, June 1, 2010, 7:14 AM
> 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.


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

Reply via email to