AS400 - How to test for connectivity
Posted on 2013-12-02
I have a Java program that interacts with an AS400 database. I am trying to code a work-around for a connectivity problem I am facing. Sometimes for various reason, after I establish a connection to the database, the connection will be lost (idle timeout, loss of network connection, etc.). In those cases, I need to be able to check whether the connection is still active, and if not, then I need to re-connect. In order to test for connectivity, I would like to simply execute some generic SQL statement and check whether it was successful. Is there any kind of generic "dummy" SQL statement or command that can be run on any AS400 system which will allow me to know whether the connection object is still valid or now?
For example, here is how I do this same operation using both Oracle and MSSQL:
Oracle: "select 'success' from dual"
MSSQL: "select 'success'"
Both of those statements work fine for Oracle and MSSQL. I am looking for something roughly equivalent on the AS400.