Hikaricp - 持续验证空闲连接

Hikari CP - Continuosly Validate Idle Connections

我观察到 Hikari 在将连接提供给请求者之前验证连接。此时,如果发现连接已死,则创建一个新连接。

是否有定期验证空闲连接的方法(即使没有人请求新连接)?

C3P0 中存在类似的东西 'idle_test_period'。

您可以定义 keepaliveTime 来验证空闲连接

 "keepalive" will only occur on an idle connection. When the time arrives for a "keepalive" against a given connection, that connection will be removed from the pool, "pinged", and then returned to the pool. The 'ping' is one of either: invocation of the JDBC4 isValid() method, or execution of the connectionTestQuery.