[英]JDBC The Network Adapter could not establish the connection/Connection reset/recv failed
I currently have a application running that needs data from a database to be able to work properly. 我目前有一个运行的应用程序需要数据库中的数据才能正常工作。
Here are the specifics: 以下是具体内容:
My problem is that I get the following error messages in infrequent intervals which results in missing data or complete shutdown of the JDBC resource. 我的问题是我在不频繁的时间间隔内收到以下错误消息,导致数据丢失或JDBC资源完全关闭。
[#|2015-10-22T16:25:42.400+0200|WARNING|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.allocator|_ThreadID=461;_ThreadName=Thread-2;|RAR5038:Unexpected exception while creating resource for pool jdbc. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: I/O-Fehler: The Network Adapter could not establish the connection|#]
Followed by 其次是
[#|2015-10-22T19:10:47.787+0200|WARNING|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool|_ThreadID=461;_ThreadName=Thread-2;|RAR5035:Unexpected exception while destroying resource from pool jdbc. Exception message: Error while destroying resource :I/O-Fehler: Unrecognized Windows Sockets error: 0: recv failed|#]
[#|2015-10-22T19:10:48.052+0200|WARNING|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool|_ThreadID=461;_ThreadName=Thread-2;|RAR5035:Unexpected exception while destroying resource from pool jdbc. Exception message: Error while destroying resource :I/O-Fehler: Connection reset|#]
Followed by 其次是
[#|2015-10-22T19:11:33.287+0200|WARNING|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool|_ThreadID=461;_ThreadName=Thread-2;|RAR5035:Unexpected exception while destroying resource from pool jdbc. Exception message: Error while destroying resource :I/O-Fehler: Socket read timed out|#]
Followed by (removed non relevant parts from my impl with ....) 接下来(从我的impl中删除不相关的部分....)
#|2015-10-23T16:35:00.087+0200|SEVERE|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource|_ThreadID=576;_ThreadName=Thread-2;|RAR5031:System Exception
javax.resource.spi.LocalTransactionException: Getrennte Verbindung
at com.sun.gjc.spi.LocalTransactionImpl.rollback(LocalTransactionImpl.java:134)
at com.sun.enterprise.resource.ConnectorXAResource.rollback(ConnectorXAResource.java:213)
at com.sun.enterprise.transaction.JavaEETransactionImpl.rollback(JavaEETransactionImpl.java:571)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.rollback(JavaEETransactionManagerSimplified.java:893)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5126)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4915)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy248.loadData(Unknown Source)
....
at sun.reflect.GeneratedMethodAccessor1663.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
....
at sun.reflect.GeneratedMethodAccessor1559.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundTimeout(SystemInterceptorProxy.java:149)
at sun.reflect.GeneratedMethodAccessor1563.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:4058)
at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1832)
at com.sun.ejb.containers.EJBTimerService.access$100(EJBTimerService.java:108)
at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:2646)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLRecoverableException: Getrennte Verbindung
at oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:3921)
at com.sun.gjc.spi.LocalTransactionImpl.rollback(LocalTransactionImpl.java:128)
... 50 more
I have programmatic fail safe which opens a new transaction to avoid a ManagedException within in my application and retries three times in case of failure. 我有程序化的故障安全,它打开一个新的事务,以避免我的应用程序内的ManagedException,并在发生故障时重试三次。
However this is apparently to not enough to ensure the stability of the JDBC connection. 但是,这显然不足以确保JDBC连接的稳定性。
What is the problem here? 这里有什么问题?
So here's what I tried and worked. 所以这就是我尝试和工作的内容。
After seeing the post in 4. I tried several configurations in Resources -> JDBC -> JDBC Connection Pools -> jdbc for timeouts etc. I though using 看到4中的帖子后,我在参考资料中选择了几个配置 - > JDBC - > JDBC连接池 - > jdbc用于超时等。我虽然使用
select 1 from SOME_TABLE;
to be the solution. 成为解决方案。 Unfortunately I made the mistake use it like this 不幸的是我犯了这样的错误
Instead of this 而不是这个
The difference by my understanding is that the first validates the connection when it goes into the pool. 根据我的理解,区别在于第一个验证连接进入池时的连接。 The second validates it when it's given out the pool to be used by a resource. 第二个验证它是在资源使用池时给出的。
Now it seems to work fine. 现在它似乎工作正常。
I hope this helps! 我希望这有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.