开发者社区> 问答> 正文

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;

展开
收起
爱吃鱼的程序员 2020-06-22 17:52:31 1126 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    sql执行慢了,连接不够用,申请连接等待超时。druid是建议自己捕获这个异常,然后等待,还是采取鸵鸟策略,直接忽略这个异常?

    <spanstyle="color:#333333;font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"><atarget="_blank"rel="nofollow">@wenshao<spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">  上次发生问题以后,完全同样的代码,把数据库连接池换成Proxool以后已经稳定运行一周,而使用<spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">Druid的话48小时内就会报这个错误。

    <spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">这个是由于慢SQL造成的吗?但是日志里面SQL执行时间基本是在5MS以下的,每秒处理的SQL不会超过20条,而我的连接个数配置为160了。

    <spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"><spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">是不是连接池泄漏了?

    <spanstyle="color:#333333;font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"><atarget="_blank"rel="nofollow">@wenshao<spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> 如果是连接池泄漏,如何定位在什么地方造成了泄漏呢?<atarget='_blank'>@千纸鹤没再用Druid了,已经换回原来的连接池。。。你用quartz是怎么用的,我在用的时候没有出现你说的异常啊,要等48小时?

    2020-06-22 17:52:50
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Java Spring Boot开发实战系列课程【第16讲】:Spring Boot 2.0 实战Apache Kafka百万级高并发消息中间件与原理解析 立即下载
《基于 Flink 的全新 Pulsar Connector 的设计、开发和使用》 立即下载
低代码开发师(初级)实战教程 立即下载