Skip to content

Commit

Permalink
Fixes brettwooldridge#1137 support changing user/password at runtime …
Browse files Browse the repository at this point in the history
…for DriverDataSource-wrapped driver connections.
  • Loading branch information
brettwooldridge authored and kollstrom committed Feb 4, 2021
1 parent ed51e53 commit 32e98a5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/com/zaxxer/hikari/util/DriverDataSource.java
Expand Up @@ -120,9 +120,18 @@ public Connection getConnection() throws SQLException
}

@Override
public Connection getConnection(String username, String password) throws SQLException
public Connection getConnection(final String username, final String password) throws SQLException
{
return getConnection();
final Properties cloned = (Properties) driverProperties.clone();
if (username != null) {
cloned.put("user", username);
cloned.put("username", username);
}
if (password != null) {
cloned.put("password", password);
}

return driver.connect(jdbcUrl, cloned);
}

@Override
Expand Down

0 comments on commit 32e98a5

Please sign in to comment.