Example #1
0
  /** Default Constructor */
  public DetIDGenerator() {
    query = new String();
    try {

      c = CDBConnection.getConnection();

      if (DetIDGenerator.export || DetIDGenerator.updateCB) {
        /*
          Just to check that we can connect to the export database
          Better to see it now rather than after all the computing...
        */
        configureExportDatabaseConnection();
        c.connect();
        c.disconnect();

        // Ok it's working, let's go!
      }

      c.setUser("prod_consult");
      c.setUrl(
          "jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ccdbcl01.in2p3.fr)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = ccdbcl02.in2p3.fr)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = cccmstrktaf.in2p3.fr)(FAILOVER_MODE =(TYPE = SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))");
      c.setPassword("am8bilo8gy");

      c.connect();
    } catch (java.sql.SQLException e) {
      Error("SQL Error : \n" + query + "\n" + e.getMessage());
    } catch (java.lang.ClassNotFoundException e) {
      Error("Can not find Oracle driver");
    }
  }
Example #2
0
  private void configureExportDatabaseConnection() throws java.sql.SQLException {
    String dbString = System.getProperty("CONFDB");
    if (dbString == null
        || dbString.equals("")
        || dbString.indexOf('/') == -1
        || dbString.indexOf('@') == -1)
      throw new java.sql.SQLException("No valid $CONFDB variable found : can not connect!");

    String user = dbString.substring(0, dbString.indexOf('/'));
    String password = dbString.substring(dbString.indexOf('/') + 1, dbString.indexOf('@'));
    String url = dbString.substring(dbString.indexOf('@') + 1, dbString.length());
    url = "jdbc:oracle:thin:@" + url;
    c.setUser(user);
    c.setUrl(url);
    c.setPassword(password);
  }