On Wed, Jan 6, 2016 at 10:10 AM, Julian Reschke <julian.resc...@gmx.de>
wrote:

> On 2016-01-06 15:21, Christopher Schultz wrote:
>
>> Julian,
>>
>> On 1/6/16 7:42 AM, Julian Reschke wrote:
>>
>>> On 2016-01-06 00:06, Christopher Schultz wrote:
>>>
>>>> Julian,
>>>>
>>>> On 1/5/16 9:25 AM, Julian Reschke wrote:
>>>>
>>>>> Hi there,
>>>>>
>>>>> maybe that's a stupid question, but why do we need a configurable
>>>>> validationQuery when there's
>>>>>
>>>>>     Connection.isValid(...)
>>>>>
>>>>> <
>>>>> https://docs.oracle.com/javase/6/docs/api/java/sql/Connection.html#isValid%28int%29
>>>>> >
>>>>>
>>>>>
>>>> Because not all JREs have the Connection.isValid method available, and
>>>> the validation query is a fall-back mechanism. Connection.isValid was
>>>> added in Java 1.6, and tomcat-pool is backward compatible down to Java
>>>> 1.5.
>>>>
>>>
>>> Ack.
>>>
>>> So if it wasn't for the required 1.5 compatibility, it could be used the
>>> default way to check the connection (still allowing an override, I
>>> assume)?
>>>
>>
>> I haven't read the code, so I don't know if tomcat-jdbc will prefer
>> Connection.isValid over an explicit validationQuery. My wild guess is
>>
>
> I'm looking at the source in trunk, and it doesn't seem to call isValid()
> ever. Are we talking about different things?
>

If you want to use Connection.isValid(), you could just make a simple
custom Validator.  It's a dead simple interface to implement.

http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/Validator.java?view=markup

You can then use the "validatorClassName" attribute on the pool to use the
custom validator instead of a validation query.

"(String) The name of a class which implements the
org.apache.tomcat.jdbc.pool.Validator interface and provides a no-arg
constructor (may be implicit). If specified, the class will be used to
create a Validator instance which is then used instead of any validation
query to validate connections. The default value is null. An example value
is com.mycompany.project.SimpleValidator."

Dan

Reply via email to