druid校验连接超过15分钟
@yzChen233 你好,想跟你请教个问题:
老师您好:
在用druid(1.1.5版本)作为impala的连接池过程中,发现连接长时间不用,等再次获取连接时校验连接是否有效花费了15分钟。
我的配置如下,testWhileIdle配置是true。看了druid的源码,发现报错的地方就是校验连接是否有效,我怀疑是connection已经断开,connection创建statement的时候耗时,请问老师是否有什么解决方案,希望得到您的回答,谢谢!
spring.datasource.initialSize=1 spring.datasource.minIdle=3 spring.datasource.maxActive=20 spring.datasource.maxWait=60000 spring.datasource.timeBetweenEvictionRunsMillis=60000 spring.datasource.minEvictableIdleTimeMillis=30000 spring.datasource.validationQuery=select 'x' spring.datasource.testWhileIdle=true spring.datasource.testOnBorrow=false spring.datasource.testOnReturn=false spring.datasource.poolPreparedStatements=true spring.datasource.maxPoolPreparedStatementPerConnectionSize=20 spring.datasource.filters=stat,wall,slf4j spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
错误日志如下:
java.sql.SQLNonTransientConnectionException: [Simba][JDBC](10060) Connection has been closed.
at com.cloudera.exceptions.ExceptionConverter.toSQLException(Unknown Source)
at com.cloudera.jdbc.common.SConnection.closeConnection(Unknown Source)
at com.cloudera.jdbc.common.SConnection.abortInternal(Unknown Source)
at com.cloudera.jdbc.common.SConnection.close(Unknown Source)
at com.alibaba.druid.util.JdbcUtils.close(JdbcUtils.java:73)
at com.alibaba.druid.pool.DruidDataSource.discardConnection(DruidDataSource.java:1322)
at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1287)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1221)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1211)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:105)
at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sinolife.sf.trace.JdbcTracePlugin.openConnection(JdbcTracePlugin.java:174)
at com.sinolife.sf.framework.dbcontext.DbSessionContextPlugin$1.invoke(DbSessionContextPlugin.java:279)
at com.sun.proxy.$Proxy141.getConnection(Unknown Source)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:151)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:371)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:415)
at com.fd.offline.impala.service.Impl.ImpalaDBServiceImpl.refresh(ImpalaDBServiceImpl.java:49)
at com.fd.offline.service.impl.ImpalaServiceImpl.refresh(ImpalaServiceImpl.java:164)
at com.fd.offline.controller.ImpalaController.refresh(ImpalaController.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
at com.fd.common.aspect.WebLogAspect.doAround(WebLogAspect.java:59)
at sun.reflect.GeneratedMethodAccessor320.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at com.sinolife.sf.framework.controller.ControllerBrowserNoCacheMethodInterceptor.invoke(ControllerBrowserNoCacheMethodInterceptor.java:19)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题我遇到过,升级了版本
并添加了属性
就可以了
我试试,谢谢老师!
这个是我的配置,我仔细对比了,下你的配置比我的少一个 “druid” 成员属性,你改成下面发的再试试看吧。