Пример #1
0
  private void connect() throws SQLException {

    String driver = datasource.getParameter(RDBMSourceParameterConstants.DATABASE_DRIVER);
    String url = datasource.getParameter(RDBMSourceParameterConstants.DATABASE_URL);

    log.debug("Connecting to JDBC source: {}", url);

    String username = datasource.getParameter(RDBMSourceParameterConstants.DATABASE_USERNAME);
    String password = datasource.getParameter(RDBMSourceParameterConstants.DATABASE_PASSWORD);
    try {
      Class.forName(driver);
    } catch (Exception e) {
      log.warn(
          "WARNING: JDBC Driver not found exception or may have been already loaded by the system.");
      // log.debug(e.getMessage(), e);
    }
    connection = DriverManager.getConnection(url, username, password);
  }
Пример #2
0
  @Override
  public void update(OBDADataSource ds) {
    if (!ds.getParameter(RDBMSourceParameterConstants.DATABASE_DRIVER).equals("org.h2.Driver")) {
      if (connection != null) {
        try {
          disconnect();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
      datasource = ds;

      try {
        connect();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }