Bug 60194 - Support for isValid, needs clarification
Summary: Support for isValid, needs clarification
Status: RESOLVED FIXED
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
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-02 14:56 UTC by peterhansson_se
Modified: 2016-11-15 05:33 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description peterhansson_se 2016-10-02 14:56:56 UTC
It is now 2016 and most people are using Java 7 or Java 8. In Java 6 the Connection.isValid() method was introduced as a way to "ping" a connection. Yet, for anyone wishing to implement Tomcat JDBC Pool it will appear to them as if they'll need to figure out and configure a validation query for each type of database that they'll be using. And I guess this is true. tomcat-jdbc doesn't take advantage of Connection.isValid(). The documentation doesn't mention anything about Connection.isValid() as an alternative to custom validation queries.

Other JDBC Pools takes the approach of using Connection.isValid() if present and otherwise falling back to custom query. 

While bug 48817 discusses this issue back in 2010, I cannot really see what came out it. 

I believe there are a number of things that can be done (in order of effort):

1. Improve documentation. What are people supposed to do?  Is the recommended approach to implement a custom Validator which would then call Connection.isValid()?  

2. Perhaps include a ready-made Validator which does just that. Then people can use it simply by adding config ("show them the path").

3. Maybe time to ditch Java 5 compatibility ?  .. meaning do what other JDBC Pools do and let Connection.isValid() be the default.
Comment 1 Keiichi Fujino 2016-11-15 05:33:48 UTC
Thanks for the report.
If validationQuery is not specified, connection validation is done by calling the isValid() method.
The fix will be in :
- 9.0.x for 9.0.0.M14 onwards
- 8.5.x for 8.5.9 onwards
- 8.0.x for 8.0.40 onwards
- 7.0.x for 7.0.74 onwards