I have a stand-alone java application that makes some database read/write business on a postgresql database. I used the isValid function available on a java.sql.Connection object in order to re-establish the database connection in case it is lost/fails possibly due to a network problem/crash. The following code snippet shows this idea shortly:
//dbConnection is an instance of java.sql.Connection
if(dbConnection.isValid(1)){
reEstablishConnection();
}
Nevertheless, at run-time I am getting an exception within the condition of above if block, which says that the method 'isValid' is not implemented yet. I am using the latest JDBC driver (v9.1-101) and my postgesql DBMS version is 8.3.9. I installed it using Yast2 on a SUSe Linux (SLES 11 SP2 - 64 bit). Can someone tell me me how I can check if the connection is lost programmatically in Java for postgresql? My inention is to reconnect automatically without the user intervention.