public class DBConnection {
public static Connection getJDBConnection(String dbUrl, String userName, String password){
Connection connection = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection(dbUrl,userName,password);
System.out.println("Database connection is successful : ");
}
catch (Exception e) {
System.out.println("Error
in Database Connection : "+e.getMessage());
}
finally{
if(connection != null){
connection.close();
}
}
return connection;
}
Note : Servicename = /OIMDEV, SID = :OIMDEV
String dbUrl =
"jdbc:oracle:thin:@HOSTNAME:1521/OIMDEV";
String userName = "dev_oim";
String password = "Welcome123";
No comments:
Post a Comment