JDBC problem while closing connection...
Posted on 2003-03-28
I have this Java app. which connect an Oracle database using JDBC. I want my application to be able to recover from a possible database-is-down. Thus I did this : Whenever the database is down and my application tries to insert data, a SQLException is thrown. My app captures that SQLException and tries to close the connection. Of course, since the database is down this will also fail. Then, it makes is JDBC connection equals "NULL" and starts looping trying to build a new connection until a valid new connection is acquired. Eventually the database will come back alive and our Java app will resume its normal operation with this new connection. However, as soon as it tries to use the new connection a SQLException is thrown: "java.sql.SQLException: Io exception: End of TNS data channel", and th app goes back to try to regain a new connection. This cycle will go forever without ever getting a JDBC connection that works. According to our Oracle guy, it seems that eventhough our Java app gets a new connection, it uses the same session while connecting the database, but because the database went down and back up that session is not valid any more.
How can I get around this????? (without restarting our Java app. If our Java app is restarted everything will work fine, but I want it to handle this by itself and regain the database connection without having to restart the app)
How can I get around this?????
thanks in advance