java.sql.SQLException: Io 异常: Broken pipe 如何在不重启的情况下恢复?

2022-01-24 00:00:00 connection oracle java recover disconnected

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

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

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.

推荐答案

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

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

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

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

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.

相关文章