コード例 #1
0
  @Override
  public ConnectionProvider getInitializedConnectionProvider() throws InvalidConnectionException {

    logger.debug("Creating new jdbc connection");

    final DriverConnectionProvider connectionProvider = new DriverConnectionProvider();
    connectionProvider.setDriver(connectionInfo.getDriver());
    connectionProvider.setUrl(connectionInfo.getUrl());

    final Properties properties = connectionInfo.getProperties();
    final Enumeration<Object> keys = properties.keys();
    while (keys.hasMoreElements()) {
      final String key = (String) keys.nextElement();
      final String value = properties.getProperty(key);
      connectionProvider.setProperty(key, value);
    }

    logger.debug("Opening connection");
    try {
      final Connection connection =
          connectionProvider.createConnection(connectionInfo.getUser(), connectionInfo.getPass());
      connection.close();
    } catch (SQLException e) {

      throw new InvalidConnectionException(
          "JdbcConnection: Found SQLException: " + Util.getExceptionDescription(e), e);
    }

    logger.debug("Connection opened");

    return connectionProvider;
  }
コード例 #2
0
  public boolean equals(final Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    final JdbcConnection that = (JdbcConnection) o;

    if (connectionInfo != null
        ? !connectionInfo.equals(that.connectionInfo)
        : that.connectionInfo != null) {
      return false;
    }

    return true;
  }
コード例 #3
0
 public int hashCode() {
   return connectionInfo != null ? connectionInfo.hashCode() : 0;
 }
コード例 #4
0
 public String getUserField() {
   return connectionInfo.getUserField();
 }
コード例 #5
0
 public String getPasswordField() {
   return connectionInfo.getPasswordField();
 }