我的应用程序使用oracle RDBMS版本12.1.0.2.0时遇到问题。 虽然我正确地连接到数据库,但有时我得到( A )一些虚假的断开连接异常
java.sql.SQLRecoverableException: IO Error: Connection reset
at java.lang.Thread.run(Unknown Source)
Suppressed: java.sql.SQLRecoverableException: Closed Connection
...
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at oracle.net.ns.Packet.receive(Packet.java:311)
at oracle.net.ns.DataPacket.receive(DataPacket.java:105)
和( B )有些时候我甚至无法创建连接
java.sql.SQLRecoverableException: IO Error: Software caused connection abort: recv failed
...
Caused by: java.net.SocketException: Software caused connection abort: recv failed
或者
Caused by: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:715)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:322)
... 6 more
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:445)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:464)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:594)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:229)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1360)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:486)
... 11 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method) [rt.jar:1.8.0_92]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) [rt.jar:1.8.0_92]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) [rt.jar:1.8.0_92]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) [rt.jar:1.8.0_92]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) [rt.jar:1.8.0_92]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) [rt.jar:1.8.0_92]
at java.net.Socket.connect(Socket.java:589) [rt.jar:1.8.0_92]
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:162)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:411)
某些应用程序正在使用带有以下独立设置的wildfly v8.2
<connection-url>connectionString</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>ojdbc7.jar</driver>
<pool>
<min-pool-size>12</min-pool-size>
<max-pool-size>24</max-pool-size>
<prefill>false</prefill>
<use-strict-min>true</use-strict-min>
</pool>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<validate-on-match>false</validate-on-match>
<background-validation>true</background-validation>
<background-validation-millis>300000</background-validation-millis>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>8</idle-timeout-minutes>
<query-timeout>0</query-timeout>
<use-try-lock>0</use-try-lock>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>0</allocation-retry-wait-millis>
</timeout>
<statement>
<track-statements>true</track-statements>
<share-prepared-statements>false</share-prepared-statements>
</statement>
其余的是使用JDBC的独立应用程序。 我已经检查了监听器日志,并根据它们,应用程序从未发送请求( B 方案)。 请注意,应用程序稍后重试并成功连接,并且应用程序部署在同一网络中。
请帮助确定原因?
谢谢。
答案 0 :(得分:0)
(A):错误表示套接字已正常关闭。这可能是微网络中断,或者它可能是应用程序和数据库之间的中间位置,当它检测到没有活动超过x秒时关闭套接字。通过将outputs
连接属性设置为oracle.net.keepAlive
,可以帮助打开保持活动状态。请注意,也可以使用true
将此属性设置为Java系统属性。
(B):如果配置了速率限制,监听器可能会拒绝套接字连接尝试,这有助于登录风暴期间。一个合适的客户端应该延迟重试。 12.1.0.2中的JDBC瘦驱动程序在URL中支持这两个参数(值以秒为单位)。例如:
-D
文档为here。