tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Iris Hupkens <>
Subject RE: Tomcat JDBC connection pool: Using initSql together with validatorClassName
Date Thu, 04 Dec 2014 10:40:16 GMT
True, using a Validator which checks if validateAction == VALIDATE_INIT and then performs the
initSql itself will work. In my situation the validatorClassName was a configurable property,
so I ended up creating a simple wrapper Validator which chooses between executing the initSql
or calling the original validator. It’s a bit unintuitive to use the validator like that,
but I’m glad to have it working ☺
Thanks for your responses!

From: Filip Hanik []
Sent: woensdag 3 december 2014 19:47
To: Tomcat Users List
Cc: Iris Hupkens
Subject: Re: Tomcat JDBC connection pool: Using initSql together with validatorClassName

You should be able to run init SQL commands yourself in your custom validator

On Wed, Dec 3, 2014 at 11:42 AM, Wes Clark <<>>
These actions seems to incorrectly conflated in the code.  I'd also like to do the same thing,
so if you get it working, keep me posted.

-----Original Message-----
From: Iris Hupkens [<>]
Sent: Wednesday, December 03, 2014 5:14 AM
To: '<>'
Subject: Tomcat JDBC connection pool: Using initSql together with validatorClassName


I am using the Tomcat JDBC connection pool (version 7.0.55) as a stand-alone library. The
connection pool is configured with a custom validator class in order to use the JDBC4 isValid
method for connection validation.  I would also like to use initSql to perform some preparation
on all connections created in the pool (such as setting sorting to case insensitive under
Oracle). However, it appears that initSql does not work in combination with a validator class.

Looking at the source, the code that executes the initSql statement is skipped if a validator
class is configured. The documentation for initSql states that it is executed in place of
the validation query when connections are initialized, but the method which does the validation
first checks if there is a validator class that should be used instead, and then returns immediately.

I was wondering: is this a bug, or is it intentionally not possible? If it's intentional,
is there perhaps a different way to configure the Tomcat connection pool to use both a custom
validator class and execute initial SQL statements when first creating a connection?

Kind regards,
Iris Hupkens
To unsubscribe, e-mail:<>
For additional commands, e-mail:<>

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message