JDBC - How can I detect a Stale Connection?
582870Nov 30 2007 — edited Dec 3 2007Hi There,
So here is my problem. My software is using a simple implementation of a connection pool to create/store/provide connections.
Every weekend the database is being shut down and restarted by my DBA. On Monday morning the application can no longer access the DB and I get errors like this:
java.sql.SQLException: No more data to read from socket
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.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1118)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1070)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:478)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:790)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1031)
at oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:830)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1124)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1264)
The connection pool is checking the connections to see if they are closed before giving them out but the check must be indicating that the connections are not closed.
What should I be checking to ensure that only live connections are passed to my application? Or do I need to change my approach to solve this problem.
Any info is greatly appreciated. Thanks.