数据库连接池获取连接时,如果testWhileIdle为true,会比较idleMills>timeBetweenEvictionRunsMills,来决定是否进行校验链接是否可用(所以保证timeBetweenEvictionRunsMills小于数据库的wait_timeout时间至关重要,否则 last package。。。)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 20,820,001 milliseconds ago. The last packet sent successfully to the server was 20,820,002 milliseconds ago.is longer than the server configured valueof'wait_timeout'. You should consider either expiring and/or testing connection validity before usein your application, increasing the server configured valuesfor client timeouts,orusing the Connector/J connection property 'autoReconnect=true'to avoid this problem.
at sun.reflect.GeneratedConstructorAccessor29.newInstance(Unknown Source)~[na:na]