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

痞子三分冷 提交于 2019-12-22 05:01:43

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/9766168/java-sql-sqlexception-io-exception-broken-pipe-how-to-recover-without-restart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!