java.sql.SQLException: Io 异常:管道破裂如何在不重启的情况下恢复?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9766168/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 07:24:07  来源:igfitidea点击:

java.sql.SQLException: Io exception: Broken pipe how to recover without restart?

javaoracleconnectionrecoverdisconnected

提问by user710818

In my application I use connection to Oracle, when connection lost and I try to re-connect I receive exception:

在我的应用程序中,我使用与 Oracle 的连接,当连接丢失并尝试重新连接时,我收到异常:

java.sql.SQLException: Io exception: Broken pipe
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:273)
    at oracle.jdbc.driver.T4CStatement.fetch(T4CStatement.java:540)
    at oracle.jdbc.driver.OracleResultSetImpl.close_or_fetch_from_next(OracleResultSetImpl.java:264)
    at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:196)

For recover I need to restart application, does it possible recover without restart? Thanks.

为了恢复,我需要重新启动应用程序,是否可以在不重新启动的情况下恢复?谢谢。

采纳答案by Korhan Ozturk

Followings could be the possibilities which could be causing the exception:

以下可能是导致异常的可能性:

  1. Network problem: That is the network between the database and application server causing the physical connection to be dropped after a period of time. It's probably due to a firewall running behind the network which is configured to kill db connections after a specified period of time. You may consider a workaround to maintain the connection alive all the time simply by re-configuring your application server. For Tomcat, you may try adding validationQuery="select 'validationQuery' from dual in the Tomcat datasource conf file (context.xml)

  2. The connections to the database server are being reset and the client is not notified by the database driver. The problem in this case is that the Oracle driver is discovering that it's socket to the DBMS somehow (firewall again, maybe?) has been closed by the other end. You may consider setting your connection timeout (in the pool) shorter than the network/DB server timeout as a solution.

  1. 网络问题:即数据库和应用服务器之间的网络,导致物理连接一段时间后断开。这可能是由于在网络后面运行的防火墙被配置为在指定的时间段后终止数据库连接。您可以考虑一种变通方法,只需重新配置应用程序服务器即可始终保持连接处于活动状态。对于 Tomcat,您可以尝试validationQuery="select 'validationQuery' from dua在 Tomcat 数据源 conf 文件(context.xml)中添加l

  2. 正在重置与数据库服务器的连接,并且数据库驱动程序不会通知客户端。在这种情况下,问题在于 Oracle 驱动程序发现它与 DBMS 的套接字以某种方式(又是防火墙,也许?)已被另一端关闭。您可以考虑将连接超时(在池中)设置为短于网络/数据库服务器超时作为解决方案。