Quartz和Druid如何配合使用?
@wenshao 你好,想跟你请教个问题:
1、我的系统运行一段时间以后,就会报错:
[ERROR] [com.xxx.app.quartz.ToExamine] - org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60003, active 7
增加maxActive的值也一样有问题,只是发生的时间间隔会加长而已。
是否在Quartz和Druid使用不当会造成连接池泄漏?二者如何配合使用?
2、详细错误:
[ERROR] [com.xxx.app.quartz.ToE] - org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60003, active 7 org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60003, active 7 at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) at org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:116) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:333) at $Proxy12.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:189) at org.apache.ibatis.binding.MapperMethod.executeForList(MapperMethod.java:85) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:65) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:38) at $Proxy36.selectReceipt(Unknown Source) at com.xxx.app.quartz.ToE.fr(ToExamine.java:67) at com.xxx.app.quartz.ToE.execute(ToExamine.java:51) at sun.reflect.GeneratedMethodAccessor291.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273) at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:264) at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86) at org.quartz.core.JobRunShell.run(JobRunShell.java:216) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60003, active 7 at 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.logging.LogFilter.dataSource_getConnection(LogFilter.java:827) at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4530) 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.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.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) ... 18 more
3、Druid版本:0.2.23;Quartz:1.8.5;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
你用quartz是怎么用的,我在用的时候没有出现你说的异常啊,要等48小时?
@千纸鹤 没再用Druid了,已经换回原来的连接池。。。
@wenshao 如果是连接池泄漏,如何定位在什么地方造成了泄漏呢?
@wenshao 上次发生问题以后,完全同样的代码,把数据库连接池换成Proxool以后已经稳定运行一周,而使用Druid的话48小时内就会报这个错误。
这个是由于慢SQL造成的吗?但是日志里面SQL执行时间基本是在5MS以下的,每秒处理的SQL不会超过20条,而我的连接个数配置为160了。
是不是连接池泄漏了?
druid 是建议自己捕获这个异常,然后等待,还是采取鸵鸟策略,直接忽略这个异常?
sql执行慢了,连接不够用,申请连接等待超时。