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) throws Exception {
//connect to database
Class.forName("oracle.jdbc.driver.OracleDriver");
String serverName = "00.000.0.000";
String portNumber = "1521";
String sid = "My Sid";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "UNAME";
String password = "PASSWORD";
Connection conn = DriverManager.getConnection(url, username, password);
}
}
What I want to do is test the database if it is reachable and if its not then the program will connect to the next database. I have 8 production database.