package com.lbslocal.cc.common;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.lbslocal.master.common.ConfigurationManager;
public class dataBase {
public static String status = "";
public static Connection getConnection(String dataBase) {
Connection conn = null;
ConfigurationManager cm = ConfigurationManager.getInstance();
try {
Class.forName(cm.getAppSettings("DB_DRIVER_NAME")).newInstance();
// String t = "jdbc:mysql://200.186.101.150/%s?useUnicode=true&characterEncoding=UTF-8";
// conn = DriverManager.getConnection(String.format(t, dataBase),
// "root",
// "lbs@@#1");
conn = DriverManager.getConnection(String.format(cm.getAppSettings("DB_URI"), dataBase),
cm.getAppSettings("DB_USER"),
cm.getAppSettings("DB_PASSWORD"));
status = "Connection opened";
} catch (SQLException e) {
status += e.getMessage();
} catch (ClassNotFoundException e) {
status += e.getMessage();
} catch (InstantiationException e) {
status += e.getMessage();
} catch (IllegalAccessException e) {
status += e.getMessage();
}
return conn;
}
}