Oracle DB : java.sql.SQLException: Closed Connection
Reasons for java.sql.SQLException: Closed Connection from Oracle??
java.sql.SQLException: Closed Connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208) at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:1131) at oracle.jdbc.OracleConnectionWrapper.commit(OracleConnectionWrapper.java:117)
We are getting this error from the fail over database connection. We use the same code for other databases as well. But seeing this issue with only one of the databases. Is this because the connection might have timeout due to long inactivity period and we are trying to use that? Pls let me know if you need more details...
AbandonedConnectionTimeout set to 15 mins InactivityTimeout set to 30 mins
It means the connection was successfully established at some point, but when you tried to commit right there, the connection was no longer open. The parameters you mentioned sound like connection pool settings. If so, they're unrelated to this problem. The most likely cause is a firewall between you and the database that is killing connections after a certain amount of idle time. The most common fix is to make your connection pool run a validation query when a connection is checked out from it. This will immediately identify and evict dead connnections, ensuring that you only get good connections out of the pool.
You have to validate the connection.
If you use Oracle it is likely that you use Oracle´s Universal Connection Pool. The following assumes that you do so.
The easiest way to validate the connection is to tell Oracle that the connection must be validated while borrowing it. This can be done with
pool.setValidateConnectionOnBorrow(true);
But it works only if you hold the connection for a short period. If you borrow the connection for a longer time, it is likely that the connection gets broken while you hold it. In that case you have to validate the connection explicitly with
if (connection == null || !((ValidConnection) connection).isValid())
See the Oracle documentation for further details.
链接地址: http://www.djcxy.com/p/61698.html上一篇: SSL断开的管道