1, problem
testOnBorrow = false leads to obtaining a connection cloes_wait.
http://commons.apache.org/proper/commons-dbcp/configuration.html official dbcp configuration
org.apache.tomcat.jdbc.pool.DataSource default data source
an interface data source org.apache.tomcat.jdbc.pool.PoolConfiguration
org.apache.tomcat.jdbc.pool.DataSourceProxy data source configuration Agent
org.apache.tomcat.jdbc.pool.PoolProperties default configuration properties
2, configuration items
validationQuery SQL query, to verify the connection removed from the connection pool, if specified, it must be a SQL SELECT query and the at least one row must return before the connection is returned to the caller.
testOnBorrow true indicates whether the test was removed from the pool before the connection, if the test fails,
Removed from the pool and connected to try to remove the other.
Note: When set to true if you want to take effect, validationQuery parameters must be set to a non empty string
testWhileIdle false indicates whether the connection is idle collector connection (if any) is tested. If the test fails,
The connection is removed from the pool.
Note: When set to true if you want to take effect, validationQuery parameters must be set to a non empty string
timeBetweenEvictionRunsMillis -1 connection idle thread sleep time value recovered during operation, in milliseconds. If a non-positive, connection recovery is not run idle thread.
3, for example
SpringCloud service, for example:
spring.datasource.remove-abandoned = true # whether to automatically connect timeout recovery
spring.datasource.remove-abandoned-timeout = 120 # timeout (in units of seconds)
spring.datasource.test-ON-BORROW = # to true detection cell in connection availability
spring.datasource.test-while-idle = true # indicates whether the connection is idle collector connected checked. If the test fails, the connection is removed from the pool.
spring.datasource.validation-query = SELECT 1; # authentication
spring.datasource.time-BETWEEN--eviction-the runs of millis = 60000 # minimum time connection pool idle connection remains idle without being recovered collector thread, the unit millisecond