示例#1
0
文件: Dots.java 项目: rcuvgd/tmlinux
 /**
  * Create a connection to database
  *
  * @param driverClassName: Database access driver class
  * @param url: Database url
  * @param dbUid: Database user id
  * @param dbPasswd: Database user password
  */
 public static Connection createConnection(
     String driverClassName, String url, String dbUid, String dbPasswd) {
   Connection con = null;
   try {
     Class.forName(driverClassName).newInstance();
     con = DriverManager.getConnection(url, dbUid, dbPasswd);
   } catch (Exception e) {
     DotsLogging.logException("Dots.createConnection: " + e);
   }
   return con;
 }
示例#2
0
文件: Dots.java 项目: rcuvgd/tmlinux
  /** Check if database connection can be established using the values from config file. */
  public static void checkDBConn() {
    try {
      Connection con = null;
      Statement stmt = null;

      Class.forName(DotsConfig.DRIVER_CLASS_NAME).newInstance();
      con = DriverManager.getConnection(DotsConfig.URL, DotsConfig.DB_UID, DotsConfig.DB_PASSWD);
      stmt = con.createStatement();
      stmt.close();
      con.close();
    } catch (Exception e) {
      DotsLogging.logException("Dots.checkDBConn: " + e.getMessage());
      System.out.println("DataBase Connect failed!");
      e.printStackTrace();
      System.exit(1);
    }
  }