Bug 60194

Summary: Support for isValid, needs clarification
Product: Tomcat Modules Reporter: peterhansson_se
Component: jdbc-poolAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

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