/** * This implementation delegates to {@code getConnectionFromDriver}, * using the given username and password. * @see #getConnectionFromDriver(String, String) */ @Override public Connection getConnection(String username, String password) throws SQLException { return getConnectionFromDriver(username, password); }
/** * Build properties for the Driver, including the given username and password (if any), * and obtain a corresponding Connection. * @param username the name of the user * @param password the password to use * @return the obtained Connection * @throws SQLException in case of failure * @see java.sql.Driver#connect(String, java.util.Properties) */ protected Connection getConnectionFromDriver(@Nullable String username, @Nullable String password) throws SQLException { Properties mergedProps = new Properties(); Properties connProps = getConnectionProperties(); if (connProps != null) { mergedProps.putAll(connProps); } if (username != null) { mergedProps.setProperty("user", username); } if (password != null) { mergedProps.setProperty("password", password); } Connection con = getConnectionFromDriver(mergedProps); if (this.catalog != null) { con.setCatalog(this.catalog); } if (this.schema != null) { con.setSchema(this.schema); } return con; }
/** * This implementation delegates to {@code getConnectionFromDriver}, * using the default username and password of this DataSource. * @see #getConnectionFromDriver(String, String) * @see #setUsername * @see #setPassword */ @Override public Connection getConnection() throws SQLException { return getConnectionFromDriver(getUsername(), getPassword()); }
/** * This implementation delegates to {@code getConnectionFromDriver}, * using the given username and password. * @see #getConnectionFromDriver(String, String) */ public Connection getConnection(String username, String password) throws SQLException { return getConnectionFromDriver(username, password); }
/** * Build properties for the Driver, including the given username and password (if any), * and obtain a corresponding Connection. * @param username the name of the user * @param password the password to use * @return the obtained Connection * @throws SQLException in case of failure * @see java.sql.Driver#connect(String, java.util.Properties) */ protected Connection getConnectionFromDriver(String username, String password) throws SQLException { Properties mergedProps = new Properties(); Properties connProps = getConnectionProperties(); if (connProps != null) { mergedProps.putAll(connProps); } if (username != null) { mergedProps.setProperty("user", username); } if (password != null) { mergedProps.setProperty("password", password); } return getConnectionFromDriver(mergedProps); }
/** * This implementation delegates to {@code getConnectionFromDriver}, * using the default username and password of this DataSource. * @see #getConnectionFromDriver(String, String) * @see #setUsername * @see #setPassword */ public Connection getConnection() throws SQLException { return getConnectionFromDriver(getUsername(), getPassword()); }
/** * This implementation delegates to {@code getConnectionFromDriver}, * using the default username and password of this DataSource. * @see #getConnectionFromDriver(String, String) * @see #setUsername * @see #setPassword */ @Override public Connection getConnection() throws SQLException { return getConnectionFromDriver(getUsername(), getPassword()); }