Skip to content

Commit 851e2d4

Browse files
Fixes #1137 support changing user/password at runtime for DriverDataSource-wrapped driver connections.
1 parent 71e8688 commit 851e2d4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/main/java/com/zaxxer/hikari/util/DriverDataSource.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,18 @@ public Connection getConnection() throws SQLException
120120
}
121121

122122
@Override
123-
public Connection getConnection(String username, String password) throws SQLException
123+
public Connection getConnection(final String username, final String password) throws SQLException
124124
{
125-
return getConnection();
125+
final Properties cloned = (Properties) driverProperties.clone();
126+
if (username != null) {
127+
cloned.put("user", username);
128+
cloned.put("username", username);
129+
}
130+
if (password != null) {
131+
cloned.put("password", password);
132+
}
133+
134+
return driver.connect(jdbcUrl, cloned);
126135
}
127136

128137
@Override

0 commit comments

Comments
 (0)