druid异常——
Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60000, active 50at com.alibaba.druid.pool.DruidDataSource.pollLast(DruidDataSource.java:1375)at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1019)at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:902)at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4534)at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:661)at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4530)at com.alibaba.druid.filter.FilterAdapter.dataSource_getConnection(FilterAdapter.java:2723)at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4530)at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:884)at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:876)at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:92)at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:139)at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:380)at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:228)... 84 more
这个异常可能是因为druid连接池溢出产生的异常。连接超时,是因为某个连接没有成功,而且没有开启druid的超时回收导致的。
原来的配置文件中druid的配置
#druid datasource
druid.initialSize=20
druid.minIdle=10
druid.maxActive=50
druid.maxWait=60000
druid.timeBetweenEvictionRunsMillis=60000
druid.minEvictableIdleTimeMillis=300000
druid.validationQuery=SELECT 'x'
druid.testWhileIdle=true
druid.testOnBorrow=false
druid.testOnReturn=false
druid.poolPreparedStatements=true
druid.maxPoolPreparedStatementPerConnectionSize=20
druid.filters=wall,stat
添加回收机制之后
#druid datasource
druid.initialSize=20
druid.minIdle=10
druid.maxActive=50
druid.maxWait=60000
druid.timeBetweenEvictionRunsMillis=60000
druid.minEvictableIdleTimeMillis=300000
druid.validationQuery=SELECT 'x'
druid.testWhileIdle=true
druid.testOnBorrow=false
druid.testOnReturn=false
druid.poolPreparedStatements=true
druid.maxPoolPreparedStatementPerConnectionSize=20
druid.filters=wall,stat#druid recycle
druid.removeAbandoned=true
druid.removeAbandonedTimeout=300
druid.logAbandoned=false
就解决了溢出的问题。