我们系统中目前设置的是jdbc.maxIdleTime=14400000 ,minIdle=20
14400000/3600/1000 = 4小时
我们的数据库目前设置为15分钟即断开。
故客户端连接池设置时间短一点:10分钟,会回收连接直到20.剩下的20个连接即使一直空闲也不回收,符合连接池的意义。但是数据库会把这20个连接关闭。故依旧无法解决
抛错或者超时的问题。
只能查看druid的监控,查看峰值活跃数。不停调整值
{
"url": "jdbc:mysql://xxxx?characterEncoding=UTF-8",
"dbType": "mysql",
"name": "DataSource-4129454",
"activeCount": 0,
"activePeak": 4,
"activePeakTime": "2016-02-16 00:00:03",
"poolingCount": 5,
"poolingPeak": 6,
"poolingPeakTime": "2016-02-15 23:59:25",
"connectCount": 8788,
"closeCount": 8787,
"executeCount": 9757,
"commitCount": 485,
"pstmtCacheHitCount": 9753,
"pstmtCacheMissCount": 4,
"startTransactionCount": 485,
"transactionHistogram": [
0,
485
],
"connectionHoldTimeHistogram": [
8274,
513
],
]
}
{
"url": "jdbc:mysql://xxx?characterEncoding=UTF-8",
"dbType": "mysql",
"name": "DataSource-4129454",
"activeCount": 0,
"activePeak": 4,
"activePeakTime": "2016-02-15 22:00:10",
"poolingCount": 4,
"poolingPeak": 4,
"poolingPeakTime": "2016-02-15 21:59:13",
"connectCount": 9354,
"closeCount": 9354,
"executeCount": 9962,
"errorCount": 1,
"commitCount": 305,
"pstmtCacheHitCount": 9956,
"pstmtCacheMissCount": 6,
"startTransactionCount": 305,
"transactionHistogram": [
0,
305
],
"connectionHoldTimeHistogram": [
8999,
353,
2
]
}