Package com.lbslocal.cc.common

Source Code of com.lbslocal.cc.common.dataBase

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;
  }
}
TOP

Related Classes of com.lbslocal.cc.common.dataBase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.