Java JDBC网络适配器无法建立连接/连接重置/recv失败
我目前有一个应用程序正在运行,需要数据库中的数据才能正常工作 具体情况如下:Java JDBC网络适配器无法建立连接/连接重置/recv失败,java,oracle,jdbc,glassfish,timeout,Java,Oracle,Jdbc,Glassfish,Timeout,我目前有一个应用程序正在运行,需要数据库中的数据才能正常工作 具体情况如下: 玻璃鱼3.1.2 Oracle DB 11.2.0.2.0(我在这里的访问权限有限) Java 7/6 JDBC库oracle-JDBC-11.2.0.3-jdk6.jar 创建新连接池时,我使用Glassfish的标准配置进行池 所使用的SQL仅用于选择,其中没有连接或其他复杂结构 根据SQL的不同,它们可以在30秒及以下轻松运行 我的问题是,我偶尔会收到以下错误消息,这会导致数据丢失或JDBC资源完全关闭 [#
- 玻璃鱼3.1.2
- Oracle DB 11.2.0.2.0(我在这里的访问权限有限)
- Java 7/6
- JDBC库oracle-JDBC-11.2.0.3-jdk6.jar
- 创建新连接池时,我使用Glassfish的标准配置进行池
- 所使用的SQL仅用于选择,其中没有连接或其他复杂结构
- 根据SQL的不同,它们可以在30秒及以下轻松运行
[#|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|#]
之后是(从我的impl中删除了不相关的部分,带有…)
我有一个程序化的fail-safe,它打开一个新事务以避免我的应用程序中出现ManagedException,并在出现故障时重试三次
然而,这显然不足以确保JDBC连接的稳定性
这里有什么问题?以下是我尝试和工作的内容
select 1 from SOME_TABLE;
这是解决办法。不幸的是,我犯了一个错误,就这样使用它
而不是这个
根据我的理解,区别在于第一个在连接进入池时验证连接。第二种方法在给出资源使用的池时验证它
[#|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|#]
现在看来效果不错
我希望这有帮助