如何调试/解决 MySQL JDBC 连接超时
Posted
技术标签:
【中文标题】如何调试/解决 MySQL JDBC 连接超时【英文标题】:How to debug/solve MySQL JDBC connection timeout 【发布时间】:2016-06-21 14:10:53 【问题描述】:我正在使用 mysql 数据库迁移 Java 应用程序。现在连接在某个时候超时,尽管具有相同参数的同一个在之前的几个事务中工作得很好。这是代码:
公共类 DBConnection
public DBConnection()
super();
public static Connection getConnection(String database, String port,
String schema, String username, String password)
throws SQLException, ClassNotFoundException
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Connecting to DB:");
Connection connection = DriverManager.getConnection("jdbc:mysql://"
+ database + ":" + port + "/" + schema, username, password);
System.out.println("Connection success: " + connection.isValid(3));
return connection;
还有我的日志:
2016-06-21 15:48:32,621 调试 [xxx] (默认任务 21)语句:LOAD DATA LOCAL INFILE 'C:/CostCenter_Data/common/date_dim.csv' INTO TABLE il_costcenter.tbl_dim_date 字段以 ',' 结尾,并由 '"' 括起来 由 ' 2016-06-21 15:48:32,621 DEBUG 终止的行 [xxx] (默认任务 21)' IGNORE 1 LINES 2016-06-21 15:48:33,011 DEBUG [xxx] (默认任务 21)连接到 DB:2016-06-21 15:48:33,011 DEBUG [xxx] 2016-06-21 15:48:33,027 调试 [xxx] (默认任务 21)连接成功:true 2016-06-21 15:48:33,027 调试 [xxx] (默认任务 21)正在执行语句... 2016-06-21 15:48:33,027 DEBUG [xxx] (默认任务 21)截断表 costcenter.tbl_dim_date 2016-06-21 15:48:33,246 调试 [xxx] (默认任务 21)连接到 DB:2016-06-21 15:48:33,246 DEBUG [xxx] (默认任务 21)连接成功:真 2016-06-21 15:48:33,246 调试 [xxx] (默认任务 21)正在执行语句... 2016-06-21 15:48:33,246 DEBUG [xxx] (默认任务 21)插入 costcenter.tbl_dim_date(date_qualifier ,week_id ,month_id ,quarter_id ,year_id ,previous_date ,last_month_date ,last_quarter_date ,last_year_date ,date_begin_ts ,date_end_ts ,day_of_week_id ,weekday_flag ,last_day_in_month ,week_begin_date ,week_end_date ) 选择 date_qualifier ,week_id ,month_id ,quarter_id ,year_id ,previous_date ,last_month_date ,last_quarter_date ,last_year_date ,date_begin_ts ,date_end_ts ,day_of_week_id ,case weekday_flag 当“真”时为真,否则为假 以 weekday_flag 结束,如果 last_day_in_month 为“真”,则为真,否则为真 false end as last_day_in_month ,week_begin_date ,week_end_date from il_costcenter.tbl_dim_date 2016-06-21 15:48:33,699 调试 [xxx] (默认任务 21)连接到数据库:2016-06-21 15:48:33,699 DEBUG 2016-06-21 15:53:31,404 警告 [com.arjuna.ats.arjuna](交易 收割者)ARJUNA012117:TransactionReaper::check timeout for TX 0:ffff0a00016d:-382678fc:5769432f:39 处于运行状态 2016-06-21 15:53:31,404 WARN [com.arjuna.ats.arjuna](交易收割工人 0) ARJUNA012095: 中止操作 id 0:ffff0a00016d:-382678fc:5769432f:39 在多线程时调用 活跃于其中。 2016-06-21 15:53:31,404 警告 [com.arjuna.ats.arjuna](交易收割工人 0)ARJUNA012381: 操作 id 0:ffff0a00016d:-382678fc:5769432f:39 完成多个 线程 - 线程默认任务 21 正在进行中 java.io.FileInputStream.readBytes(本机方法) java.io.FileInputStream.read(未知来源) java.io.BufferedInputStream.read1(未知来源) java.io.BufferedInputStream.read(未知来源) sun.nio.cs.StreamDecoder.readBytes(未知来源) sun.nio.cs.StreamDecoder.implRead(未知来源) sun.nio.cs.StreamDecoder.read(未知来源) java.io.InputStreamReader.read(未知来源) java.io.BufferedReader.fill(未知来源) java.io.BufferedReader.readLine(未知来源) java.io.BufferedReader.readLine(未知来源) xxx sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) sun.reflect.NativeMethodAccessorImpl.invoke(未知来源) sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) java.lang.reflect.Method.invoke(未知来源) org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437) org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82) org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93) org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:57) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:125) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437) org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64) org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:65) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:254) org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:329) org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:66) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636) org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:195) org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73) xxxPersistenceService$$$view3.invokeTEL(未知 来源) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(未知来源) sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) java.lang.reflect.Method.invoke(未知来源) org.jboss.weld.util.reflection.Reflections.invokeAndUnwrap(Reflections.java:436) org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:127) org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56) org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100) xxx.PersistenceService$Proxy$_$$Weld$EnterpriseProxy$.invokeTEL(未知 来源) xxx.PersistenceService$Proxy$$$WeldClientProxy.invokeTEL(未知 来源) xxx.FileManagementService.archiveFile(FileManagementService.java:83) sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) sun.reflect.NativeMethodAccessorImpl.invoke(未知来源) sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) java.lang.reflect.Method.invoke(未知来源) org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437) org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82) org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93) org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437) org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64) org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327) org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:66) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636) org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:195) org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73) xxx.FileManagementService$$$view6.archiveFile(未知 来源) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(未知来源) sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) java.lang.reflect.Method.invoke(未知来源) org.jboss.weld.util.reflection.Reflections.invokeAndUnwrap(Reflections.java:436) org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:127) org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56) org.jboss.weld.bean.proxy.InjectionPointPropagatingEnterpriseTargetBeanInstance.invoke(InjectionPointPropagatingEnterpriseTargetBeanInstance.java:67) org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100) xxx.FileManagementService$Proxy$$$_Weld$EnterpriseProxy$.archiveFile(未知 来源) xxx.FileManagementController.archiveFile(FileManagementController.java:154) sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) sun.reflect.NativeMethodAccessorImpl.invoke(未知来源) sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) java.lang.reflect.Method.invoke(未知来源) javax.el.ELUtil.invokeMethod(ELUtil.java:308) javax.el.BeanELResolver.invoke(BeanELResolver.java:415) javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256) com.sun.el.parser.AstValue.invoke(AstValue.java:285) com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304) org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87) com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) org.primefaces.application.DialogActionListener.processAction(DialogActionListener.java:45) javax.faces.component.UICommand.broadcast(UICommand.java:315) javax.faces.component.UIData.broadcast(UIData.java:1108) javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790) javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) javax.faces.webapp.FacesServlet.service(FacesServlet.java:658) io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:78) io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56) io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284) io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263) io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174) io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793) java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源) java.util.concurrent.ThreadPoolExecutor$Worker.run(未知来源) java.lang.Thread.run(未知来源)
2016-06-21 15:53:31,436 警告 [com.arjuna.ats.arjuna](交易 Reaper Worker 0) ARJUNA012108: CheckedAction::check - 原子动作 0:ffff0a00016d:-382678fc:5769432f:39 在 1 个线程处于活动状态时中止! 2016-06-21 15:53:31,436 WARN [org.jboss.as.txn](交易收割者 Worker 0) WFLYTX0027: pre-jca 同步 org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor$StatefulSessionSynchronization@e921ad 与 tx TransactionImple 完成后失败:java.lang.IllegalMonitorStateException 在 org.jboss.as.ejb3.tx.OwnableReentrantLock.unlock(OwnableReentrantLock.java:120) 在 org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.releaseLock(StatefulSessionSynchronizationInterceptor.java:181) 在 org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.releaseInstance(StatefulSessionSynchronizationInterceptor.java:173) 在 org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor$StatefulSessionSynchronization.afterCompletion(StatefulSessionSynchronizationInterceptor.java:250) 在 org.jboss.as.txn.service.internal.tsr.JCAOrderedLastSynchronizationList.afterCompletion(JCAOrderedLastSynchronizationList.java:147) 在 com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.afterCompletion(SynchronizationImple.java:96) 在 com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.afterCompletion(TwoPhaseCoordinator.java:545) 在 com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.afterCompletion(TwoPhaseCoordinator.java:476) 在 com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.cancel(TwoPhaseCoordinator.java:130) 在 com.arjuna.ats.arjuna.AtomicAction.cancel(AtomicAction.java:215) 在 com.arjuna.ats.arjuna.coordinator.TransactionReaper.doCancellations(TransactionReaper.java:381) 在 com.arjuna.ats.internal.arjuna.coordinator.ReaperWorkerThread.run(ReaperWorkerThread.java:78)
2016-06-21 15:53:31,436 警告 [com.arjuna.ats.arjuna](交易 收割工人 0) ARJUNA012121: TransactionReaper::doCancellations worker Thread[Transaction Reaper Worker 0,5,main] 成功 取消 TX 0:ffff0a00016d:-382678fc:5769432f:39
JDBC 版本与 DB-MySQL 版本匹配,我不知道去哪里看或考虑哪些错误源了。 哦,超时设置为 5 分钟,所以不是这样。
非常感谢您的帮助!
附:应用程序和数据库都在同一个安全的 Windows 服务器上运行,我通过 localhost:3306 访问,外部访问被阻止
【问题讨论】:
Gut-Feeling:您在某处有连接泄漏,并且在某些时候无法创建 MySQL 的新客户端。您如何确保在使用后关闭所有连接?也许考虑使用连接池 你说的是同一个。你的意思是同一个CSV文件?如果不是,成功与错误的文件大小是多少? 奇怪的是,从上到下的时间差正好是5分钟。您引用的相同 5 分钟值。 你应该做的是拥有你自己的小日志文件,以追加模式写入。在开始通话之前,写下开头。最后,写一个结尾。显然在行上包含时间戳(人类可读的首选,而不是 unixtimestamp,除非那是你的事)。如果您发现发生了令人讨厌的事情,请解决它。对于LOAD DATA INFILE
,在输出中包含带有该时间戳的文件名。如果文件太大,请将其拆分或调整超时值。
不,相同的连接(或至少相同的参数)。连接限制设置为默认值 151,因此不能这样(尽管池确实会更好)。 LOAD data INFILE 语句有效,它是插入超时。在甚至不需要一秒钟的旧机器上,如果我在 MySQL 工作台中本地运行它,它也会在那个时候完成。所以事务在指定的 5 分钟后确实超时,但不是因为语句过大或语句的性能问题
【参考方案1】:
当这个问题发生时检查 mysql 建立了多少个连接 - 你可以使用:
mysql> SHOW FULL PROCESSLIST;
它将为您提供有关打开的 MySQL 数据库连接数的信息。
也许可以尝试使用 setAutocommit(true) 或者如果有很多数据(性能问题)使用批处理模式并连续插入数据并在每个之后提交。
【讨论】:
已经看过了,但不是这样,因为应用程序是唯一访问数据库的应用程序。很好的提示:)【参考方案2】:我解决了这个问题。 我认为这是 java.sql.DriverManager 中的这段代码,但我无法验证。我的猜测是同步阻塞了某些东西,因为连接泄漏不是问题(原始代码中返回的连接用于 try 块,因为 java 7 或 8 自动关闭了所有实现 Autocloseable 接口的东西)
private static Connection getConnection(
String url, java.util.Properties info, Class<?> caller) throws SQLException
/*
* When callerCl is null, we should check the application's
* (which is invoking this class indirectly)
* classloader, so that the JDBC driver class outside rt.jar
* can be loaded from here.
*/
ClassLoader callerCL = caller != null ? caller.getClassLoader() : null;
synchronized(DriverManager.class)
// synchronize loading of the correct classloader.
if (callerCL == null)
callerCL = Thread.currentThread().getContextClassLoader();
我所做的是使用连接池:
http://www.javatips.net/blog/dbcp-connection-pooling-example
【讨论】:
以上是关于如何调试/解决 MySQL JDBC 连接超时的主要内容,如果未能解决你的问题,请参考以下文章
第一个项目MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
关于MySQL的wait_timeout连接超时问题报错解决方案
关于MySQL的wait_timeout连接超时问题报错解决方案