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 SQLException class provides information on a database access error. Each SQLException provides several kinds of information: a string describing the error. This is used as the Java Exception message, and is available via the getMesage() method. A "SQLstate" string which follows the XOPEN SQLstate conventions.
SQLException: Invalid state, the Connection object is closed.
To resolve, create a tns-entry having same value as the string. String is considered as Oracle database service that is present on Oracle Server and registered with listener and the connection is successful. String is considered as SID, and the connection is successful.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With