JDBC网络适配器无法建立连接/连接重置/接收失败 [英] JDBC The Network Adapter could not establish the connection/Connection reset/recv failed

查看:166
本文介绍了JDBC网络适配器无法建立连接/连接重置/接收失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在运行一个应用程序,该应用程序需要数据库中的数据才能正常工作.

I currently have a application running that needs data from a database to be able to work properly.

以下是详细信息:

  • 玻璃鱼3.1.2
  • Oracle DB 11.2.0.2.0(我在这里访问受限)
  • Java 7/JEE6
  • JDBC库oracle-jdbc-11.2.0.3-jdk6.jar
  • 在创建新的连接池时,我使用Glassfish的标准配置进行池化
  • 所使用的SQL仅是内部没有联接或其他复杂结构的选择
  • 根据SQL,它们可以在30秒及以下的时间内轻松运行

我的问题是,我不经常收到以下错误消息,这会导致数据丢失或JDBC资源完全关闭.

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.

[#|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|#]

其次是

[#|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|#]

之后

 [#|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 ....)

   #|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

我具有程序化故障保护功能,该功能可以打开新事务以避免应用程序内出现ManagedException,并在失败的情况下重试3次.

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.

但是,这显然不足以确保JDBC连接的稳定性.

However this is apparently to not enough to ensure the stability of the JDBC connection.

这是什么问题?

推荐答案

所以这就是我尝试过的工作.

So here's what I tried and worked.

  1. IO错误:网络适配器无法建立连接 ->数据库正在运行,URL正确,防火墙已使用自定义ping脚本进行了测试
  2. java.net.SocketException:无法识别Windows套接字错误:0:JVM_Bind(JBOSS)-> PC是一台win7计算机,但是参数-Djava.net.preferIPv4Stack = true没有帮助
  3. 网络适配器无法建立连接- Oracle 11g ->用上面列出的新版本替换我原来的jdbc 6 Jar,不能解决问题
  4. Java JDBC连接状态->这引起了我的思考
  1. IO Error: The Network Adapter could not establish the connection -> Database was running, URL was correct, Firewall was tested with a custom ping script
  2. java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind (JBOSS) -> The pc was a win7 machine however the argument -Djava.net.preferIPv4Stack=true didn't help
  3. The network adapter could not establish the connection - Oracle 11g -> Replaced my original jdbc 6 Jar with new one listed above, didn't solve the problem
  4. Java JDBC connection status -> This got my thinking

看完4中的帖子后,我尝试了参考资料-> JDBC-> JDBC连接池-> jdbc中的几种配置来进行超时等.我虽然使用了

After seeing the post in 4. I tried several configurations in Resources -> JDBC -> JDBC Connection Pools -> jdbc for timeouts etc. I though using

select 1 from SOME_TABLE;

成为解决方案.不幸的是,我像这样使用它时犯了错误

to be the solution. Unfortunately I made the mistake use it like 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.

现在看来工作正常.

我希望这会有所帮助!

这篇关于JDBC网络适配器无法建立连接/连接重置/接收失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆