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 that if a validationQuery is supplied, it will be used regardless of the underlying JRE's capabilities (because anyone configuring it would expect the validationQuery to be used). If you have a modern JRE, you ought to be able to rely on Connection.isValid. > If that's the case, it might make sense to use it anyway (via > reflection)... Since Java 1.6 (or later) is used to build tomcat-jdbc, there is no need to use reflection to make those calls, though that may be the way it's done. Checking the version number of the JRE is also a possibility. -chris --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org