Is there a way to test my connection to oracle database using Java? Here\'s my code.
public class OracleConnection {
public static void main(String[] args)
DriverManager#getConnection
it self attempts to establish a connection to the given database URL. The DriverManager attempts to select an appropriate driver from the set of registered JDBC drivers. and thorws SQLException
if a database access error occurs.
you can test you connection is valid or not with Connection#isValid(int timeout) returns true if the connection has not been closed and is still valid.
...
Connection conn = DriverManager.getConnection(url, username, password);
boolean reachable = conn.isValid(10);// 10 sec