码迷,mamicode.com
首页 > 其他好文 > 详细

Druid “loopWaitCount 0, wait millis 6001” 报错

时间:2017-04-12 10:13:26      阅读:1911      评论:0      收藏:0      [点我收藏+]

标签:connection   “loopwaitcount 0   druid   wait millis 6001”   

    今天总结下自己使用Druid遇到的一个错误“loopWaitCount 0, wait millis 6001”

报错信息:

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: 
Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: 
loopWaitCount 0, wait millis 6001
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80)
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:66)
at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:279)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:69)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:124)
at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:46)
at com.tzt.workLog.core.mybatis.plugin.SelectCountSqlInterceptor.intercept(SelectCountSqlInterceptor.java:49)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:57)
at com.sun.proxy.$Proxy155.query(Unknown Source)
at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:46)
at com.tzt.workLog.core.mybatis.plugin.OffsetLimitInterceptor.intercept(OffsetLimitInterceptor.java:53)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:57)
at com.sun.proxy.$Proxy155.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:101)
... 55 more

    系统用的框架是Spring+SpringMVC+Mybatis(SSM),其中把涉及到的两个配置部分列出来:

spring_service.xml
<!-- 配置数据库连接 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<!-- 基本属性 url、user、password -->
<property name="driverClassName" value="${jdbc-0.druid.driver-class}" />
<property name="url"             value="${jdbc-0.druid.driver-url}" />
<property name="username"        value="${jdbc-0.user}" />
<property name="password"        value="${jdbc-0.password}" />
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="${jdbc-0.druid.connection-initial-size}" />
<property name="minIdle"     value="${jdbc-0.druid.connection-minimum-size}" />
<property name="maxActive"   value="${jdbc-0.druid.connection-maximum-size}" />
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait"     value="${jdbc-0.druid.connection-maxwait-time}" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="${jdbc-0.druid.connection-maxactive-time}" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis"    value="${jdbc-0.druid.connection-minlive-time}" />
<property name="validationQuery" value="${jdbc-0.druid.connection-test-sql}" />
<property name="testWhileIdle"   value="${jdbc-0.druid.test-while-idle}" />
<property name="testOnBorrow"    value="${jdbc-0.druid.test-on-borrow}" />
<property name="testOnReturn"    value="${jdbc-0.druid.test-on-return}" />
<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
<property name="poolPreparedStatements" value="${jdbc-0.druid.pool-prepared-statements}" />
<!-- property name="maxPoolPreparedStatementPerConnectionSize" value="20" /-->
<!-- 数据库密码是否加密 -->
<property name="connectionProperties" value="config.decrypt=${jdbc-0.druid.config.decrypt}" />
   <!-- 配置监控统计拦截的filters -->
<property name="filters" value="stat,config"/>
</bean>
    db.properties:
    
jdbc-0.druid.alias=productDBPool
localhost
jdbc-0.druid.driver-class=com.mysql.jdbc.Driver
jdbc-0.druid.driver-url=jdbc:mysql://127.0.0.1:3306/zentao?useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
jdbc-0.user=root
jdbc-0.password=root
jdbc-0.druid.connection-initial-size=10
jdbc-0.druid.connection-minimum-size=10
jdbc-0.druid.connection-maximum-size=200
jdbc-0.druid.connection-maxwait-time=6000
jdbc-0.druid.connection-maxactive-time=6000
jdbc-0.druid.connection-minlive-time=300000
jdbc-0.druid.connection-test-sql=select 1 from dual
jdbc-0.druid.pool-prepared-statements=false
jdbc-0.druid.test-while-idle=true
jdbc-0.druid.test-on-borrow=false
jdbc-0.druid.test-on-return=false
jdbc-0.druid.config.decrypt=false


总结,原因应该是配置中jdbc-0.druid.connection-maximum-size值设置太小,刚开始设置50,后来设置为200

本文出自 “专注于开发技术” 博客,请务必保留此出处http://bingge2015.blog.51cto.com/4332222/1915103

Druid “loopWaitCount 0, wait millis 6001” 报错

标签:connection   “loopwaitcount 0   druid   wait millis 6001”   

原文地址:http://bingge2015.blog.51cto.com/4332222/1915103

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!