赞
踩
这两天碰到一个问题,在正常查询数据时,没有问题,但在使用多线程查询数据导出时,会报以下错误:
2020-05-21 08:40:36.639 WARN [charger-business,,,] 13736 --- [ool-20-thread-6] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@167038d (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value. 2020-05-21 08:40:36.686 ERROR [charger-business,4ac1589793274508,eda600f847a74923,true] 13736 --- [ XNIO-1 task-5] c.p.c.b.s.i.TOrderChargingServiceImpl : 多线程查询导出数据失败,查询参数:{"current":1,"mergeOrderFlag":0,"settlementEndTime":"2020-06-01","settlementStartTime":"2020-04-01","size":20},具体错误:{} java.util.concurrent.ExecutionException: org.springframework.dao.TransientDataAccessResourceException: ### Error querying database. Cause: java.sql.SQLException ### The error may exist in file [F:\IDEA_Workspace\Platform20190828\charger-business\charger-business-biz\target\classes\mapper\TOrderChargingMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: select a.`id`, a.`uuid`, a.`order_no`, a.`order_name`, CASE a.`is_over` WHEN 0 THEN '未完成' WHEN 1 THEN '已完成' WHEN 2 THEN '异常订单' ELSE '未知状态 ' END AS is_over, CASE a.`receive_flag` WHEN 1 THEN '已上报' WHEN 2 THEN '待上报' ELSE '未上报' END AS receive_flag, a.`user_id`, a.`user_name`, a.`vin`, CASE a.`user_type` WHEN 0 THEN 'APP' WHEN 1 THEN '刷卡' WHEN 2 THEN 'VIN' WHEN 3 THEN '企业用户' WHEN 4 THEN '微信公众号' WHEN 5 THEN '互联互通' ELSE '未知类型' END AS user_type, a.`agent_id`, a.`agent_name`, CASE ifnull(a.`company_flag`,0) WHEN 0 THEN '普通订单' WHEN 1 THEN '企业订单' ELSE '未知类型订单' END AS company_flag, a.`company_id`, a.`company_name`, CASE ifnull(a.`order_type`,1) WHEN 1 THEN '刷卡在线充电' WHEN 2 THEN '移动app充电' WHEN 3 THEN 'vin充电' WHEN 4 THEN '刷卡离线充电' WHEN 5 THEN '微信公众号充电' WHEN 6 THEN '微信小程序充电' ELSE '未知类型订单' END AS order_type, CASE a.`order_flag` WHEN 0 THEN '平台订单' WHEN 1 THEN '第三方平台订单' ELSE '未知订单标志' END AS order_flag, CASE a.`pay_status` WHEN 0 THEN '未支付' WHEN 1 THEN '已支付' ELSE '未知状态' END AS pay_status, a.`start_time`, a.`end_time`, CASE a.`charging_type` WHEN 1 THEN '电量控制充电' WHEN 2 THEN '时间控制充电' WHEN 3 THEN '金额控制充电' WHEN 4 THEN '自动充满05' WHEN 5 THEN '定时启动充电' ELSE '未知充电方式' END charging_type, a.`charging_number`, a.`charging_mark`, a.`start_soc`, a.`end_soc`, a.`total_elec`, a.`start_meter`, a.`end_meter`, a.`start_amount`, a.`end_amount`, a.`charging_fee`, a.`service_fee`, a.`total_amount`, a.`actual_amount`, a.`service_id`, CASE a.`invoice_flag` WHEN 0 THEN '不开发票' ELSE '开具发票' END AS invoice_flag, a.`pile_id`, a.`pile_sn`, a.`pile_name`, a.`communication_sn`, a.`drive_no`, a.`gun_id`, a.`gun_no`, a.`tcu_sn`, CASE a.`gun_type` WHEN 0 THEN '交流' WHEN 1 THEN '直流' WHEN 2 THEN'交直流一体' ELSE '' END AS gun_type, a.`station_id`, a.`station_name`, CASE a.`parking_fee_flag` WHEN 0 THEN '免费' ELSE '收费' END AS parking_fee_flag, a.`stop_reason`, a.`create_by`, a.`create_time`, a.`update_by`, a.`update_time`, CASE WHEN a.`total_time` IS NULL THEN CONCAT(0,'小时',0,'分',0,'秒') WHEN a.`total_time` >= 60 THEN CONCAT(floor(a.`total_time`/3600),'小时',floor(a.`total_time`%3600/60), '分',a.`total_time`%3600%60%60,'秒') ELSE CONCAT(0,'小时',0,'分',a.`total_time`,'秒')END total_time, a.`user_short_id`, a.`vendor_id`, a.`stop_details`, CASE a.`stop_status` WHEN 0 THEN '正常结束' WHEN 1 THEN '异常结束' ELSE '' END AS stop_status FROM `t_order_charging` a WHERE a.settlement_time >= ? and a.settlement_time <= ? and a.merge_order_flag = ? and a.del_flag = 0 order by id desc limit ?,? ### Cause: java.sql.SQLException ; null; nested exception is java.sql.SQLException at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at com.platform.charger.business.service.impl.TOrderChargingServiceImpl.mutiThreadQueryExportList(TOrderChargingServiceImpl.java:1647) at com.platform.charger.business.service.impl.TOrderChargingServiceImpl.getExportList(TOrderChargingServiceImpl.java:760) at com.platform.charger.business.service.impl.TOrderChargingServiceImpl$$FastClassBySpringCGLIB$$f4f68c25.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684) at com.platform.charger.business.service.impl.TOrderChargingServiceImpl$$EnhancerBySpringCGLIB$$b6e72552.getExportList(<generated>) at com.platform.charger.business.controller.ChargerOrderController.exportOrderlist(ChargerOrderController.java:209) at com.platform.charger.business.controller.ChargerOrderController$$FastClassBySpringCGLIB$$8a7a3b8e.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) 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.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88) at com.platform.charger.common.log.aspect.SysLogAspect.around(SysLogAspect.java:31) 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:498) 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:175) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:69) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at com.platform.charger.business.controller.ChargerOrderController$$EnhancerBySpringCGLIB$$369bd48.exportOrderlist(<generated>) 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:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908) at javax.servlet.http.HttpServlet.service(HttpServlet.java:665) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.cloud.sleuth.instrument.web.ExceptionLoggingFilter.doFilter(ExceptionLoggingFilter.java:50) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at brave.servlet.TracingFilter.doFilter(TracingFilter.java:86) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.dao.TransientDataAccessResourceException: ### Error querying database. Cause: java.sql.SQLException ### The error may exist in file [F:\IDEA_Workspace\Platform20190828\charger-business\charger-business-biz\target\classes\mapper\TOrderChargingMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: select a.`id`, a.`uuid`, a.`order_no`, a.`order_name`...... FROM `t_order_details` a WHERE a.del_flag = 0 order by id desc limit ?,? ### Cause: java.sql.SQLException ; null; nested exception is java.sql.SQLException at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:110) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy.$Proxy175.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:158) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:76) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:62) at com.sun.proxy.$Proxy237.getExportList(Unknown Source) at com.platform.charger.business.service.impl.TOrderChargingServiceImpl$1.call(TOrderChargingServiceImpl.java:1656) at com.platform.charger.business.service.impl.TOrderChargingServiceImpl$1.call(TOrderChargingServiceImpl.java:1654) at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) at java.util.concurrent.FutureTask.run(FutureTask.java) ... 3 common frames omitted Caused by: java.sql.SQLException: null at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370) at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java) 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:498) at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) at com.sun.proxy.$Proxy368.execute(Unknown Source) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) at sun.reflect.GeneratedMethodAccessor437.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy367.query(Unknown Source) at sun.reflect.GeneratedMethodAccessor437.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy367.query(Unknown Source) at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:67) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) 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:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ... 13 common frames omitted
根据错误提示,查看问题:
Cause: java.sql.SQLException
; null; nested exception is java.sql.SQLException
Caused by: java.sql.SQLException: null,
Caused by: org.springframework.dao.TransientDataAccessResourceException:
这些提示看不出问题,那就把SQL语句抓出来在数据库执行下。。发现SQL语句也是正常的。
那好吧,,我仔细找一下错误,,发现在报错前,有一个警告提示:
HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@167038d (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
根据提示所说,修改 配置中的 maxLifetime值,
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
hikari :
max-lifetime: 1200000
connection-timeout: 60000
validation-timeout: 3000
idle-timeout: 30000
minimum-idle: 10
maximum-pool-size: 10
connection-test-query: select 1
重启后发现没有什么用。。。
去网上搜索了一下相关问题,,大部分也是说修改maxLifetime值。。
好吧,,去找一下作者怎么说吧。。
上图翻译过来是说在五种情况下HikariCP会关闭连接,分别是连接验证失败、连接闲置时间超过idleTimeout、一个连接到达了它maxLifetime、用户手动驱逐连接、一个JDBC调用抛出一个不可恢复的 SQLException。
在搜索个问题,,现时搜索到了另外一篇博文,也记载了相关的问题,而且给出查找过程及解决原因:
http://www.iocoder.cn/HikariCP/zhazhawangzi/poan-1/
参考其解决方法,发现跟我现在的情况很是相似。先说一下我的开发环境。
我的内部网络地址:10.11.1.111
mysql数据库地址:192.168.18.11
因为我的电脑与mysql数据库不在同一网段,之前两个网段是无法通信的,但经过网络部处理后,使得我方网段可以访问18段的个别地址,注意,不是全部可以访问18段的地址。。估计也是使用了代理或桥接的方式。。
那就把项目部署到mysql所在的服务器试试。。。。
结果完美解决……
坑…………
有遇到这个坑的,欢迎留言讨论。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。