Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 555
Java Guy Avatar asked Jul 22 '11 03:07

Java Guy


People also ask

What is Java SQL SQLRecoverableException closed connection?

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.

What is Java SQL SQLException?

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.

Which exception is thrown when connection object is closed?

SQLException: Invalid state, the Connection object is closed.

Could not connect via JDBC Listener refused the connection with the following error?

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.


1 Answers

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.

like image 142
Ryan Stewart Avatar answered Oct 11 '22 10:10

Ryan Stewart