- 
                Notifications
    You must be signed in to change notification settings 
- Fork 41.6k
Description
To add a bit more context on why i ask this. We have noticed that in our database there are a lot of select 1 from dual queries. which is neither a heavy query or bad..but do we really need to run a query to validate the datasource?
isn't a simple (with the reasonable try-catch blocks of-course)
datasource.getConnections().close();enough?
or for extra validation
datasource.getConnections().isValid();both the above 2 approaches will result in the same behaviour as the existing one with better timeout handing in some jdbc drivers (for example for oracle).
Besides, all datasource pools, are already doing validation according to their configs in an optimal way.
for example have a look at micronaut's health indicator
single simple file, database agnostic.
I believe this will simplify a lot the health check, and dba's around the world will be happy as well
If the community does not feel comfortable enough with jdbc driver validation mechanisms in general ( i don't see why not) , maybe we could add a property to control whether datasourceHelathIndicator should run a query, or rely on the jdbc driver isValid method.
besides, this looks like a double config problem,
we specify in one place how hikari (personally i chose the isValid method of the jdbc driver) validates, and then there is the datasourceHealthIndicator which is overriding this validation scheme.
this probably fixes: #4391 . At least for oracle, as in oracle drivers, the connection.isValid() respects the timeout that is configured in the pool. Probably same applies in other jdbc drivers