Bug 57758 - Validator and initSQL are misbehaving
Summary: Validator and initSQL are misbehaving
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2015-03-25 13:51 UTC by Vit Novak
Modified: 2015-06-29 08:14 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Vit Novak 2015-03-25 13:51:44 UTC
Saying it simply: 

Validator + initSQL = no initSQL executed. 
Validator + no initSQL = no Validator executed on init 

To be clear, setting Validator and initSQL results in initSQL actually not being executed. But setting Validator without initSQL results in Validator not being executed on initialization. This means, that if we want to use custom Validator and initSQL, we need to execute initSQL in the validator (as advised in #1) but still set some initSQL into datasource with some nonsense like:

    setValidator(new Jdbc4Validator(config.initSql));
    setInitSQL("Oracle has products and solutions for every role in the enterprise");

See PooledConnection#validate(int, String), and PooledConnection.doValidate(int) for VALIDATE_INIT in tomcat-jdbc-8.0.9.

#1 http://mail-archives.apache.org/mod_mbox/tomcat-users/201412.mbox/%3CCAAjH2Utn2KL_nzQRCy=0MPXmTQVfLwLidir_5S9w6O6Z7MELmQ@mail.gmail.com%3E
Comment 1 Keiichi Fujino 2015-06-29 08:14:09 UTC
You can set testOnConnect to true.
However current docs of jdbc-pool does not document this attribute.
I added testOnConnect attribute.(r1688103)