/** Looks up the local database, creating if necessary. */
  private DataSource findDatabaseImpl(String url, String driverName) throws SQLException {
    try {
      synchronized (_databaseMap) {
        DBPool db = _databaseMap.get(url);

        if (db == null) {
          db = new DBPool();

          db.setVar(url + "-" + _gId++);

          DriverConfig driver = db.createDriver();

          ClassLoader loader = Thread.currentThread().getContextClassLoader();

          Class driverClass = Class.forName(driverName, false, loader);

          driver.setType(driverClass);
          driver.setURL(url);

          db.init();

          _databaseMap.put(url, db);
        }

        return db;
      }
    } catch (RuntimeException e) {
      throw e;
    } catch (SQLException e) {
      throw e;
    } catch (Exception e) {
      throw ConfigException.create(e);
    }
  }
Exemplo n.º 2
0
 public static void main(String[] args) {
   try {
     DBPool pool = new DBPool();
     Connection connection = pool.getConnection();
     release(connection, null, null);
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 3
0
 public CDRServer()
 {
     dbpool = new DBPool();
     gateway = new GatewayCDR();
     Preference.loadProperties("gateway.cfg");
     FtpData.loadProperties("ftp2cdrserver.cfg");
     break MISSING_BLOCK_LABEL_51;
     IOException e;
     e;
     Logger.info("CDRServer:", "khong tim thay file cau hinh");
     dbpool;
     DBPool.ConfigDB();
     Logger.setLogWriter("log/cdr${yyyy-MM-dd}.log");
     break MISSING_BLOCK_LABEL_72;
     IOException ex;
     ex;
     Logger.setLogLevel("info,warn,error,crisis");
     return;
 }