Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to reset password via HikariConfigMXBean at runtime!!! #1137

Closed
yuanpli opened this issue Apr 20, 2018 · 6 comments
Closed

Fail to reset password via HikariConfigMXBean at runtime!!! #1137

yuanpli opened this issue Apr 20, 2018 · 6 comments

Comments

@yuanpli
Copy link

yuanpli commented Apr 20, 2018

Environment

HikariCP version: 3.1.0
JDK version     : 1.8.0_161
Database        : Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
Driver version  : ojdbc7 12.1.0.1

Code

DataSource

HikariDataSource dataSource = new HikariDataSource();
            dataSource.setMaximumPoolSize(40);
            dataSource.setUsername(user);
            dataSource.setPassword(password);
            dataSource.setDriverClassName(driverClassName);
            dataSource.setRegisterMbeans(true);
            dataSource.setJdbcUrl(url);

Reset Password

HikariDataSource hikariDataSource = (HikariDataSource) dataSource;
hikariDataSource.getHikariConfigMXBean().setPassword("newPassword");
hikariDataSource.getHikariPoolMXBean().softEvictConnections();

Seems that new username and password are not set into driverProperties when calling function getConnection(String username, String password) in class DriverDataSource.

   @Override
   public Connection getConnection(String username, String password) throws SQLException
   {
      return getConnection();
   }

It works in my testing after changed above code to

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

Hi @brettwooldridge,
Could you kindly share your comment? Thanks!

@yuanpli
Copy link
Author

yuanpli commented May 14, 2018

Any update for this issue? Is it a known issue? Is there any plan/schedule when it will be fixed?

@yuanpli yuanpli changed the title Changing username or password is not working via HikariConfigMXBean at runtime Failed to reset password via HikariConfigMXBean at runtime!!! May 14, 2018
@yuanpli yuanpli changed the title Failed to reset password via HikariConfigMXBean at runtime!!! Fail to reset password via HikariConfigMXBean at runtime!!! May 14, 2018
@brettwooldridge
Copy link
Owner

brettwooldridge commented May 14, 2018

I’ll take a look. I don’t have the code in front of me but it’s possible that the password change is only wired through for pure DataSources and not wrapped driver DataSources.

brettwooldridge added a commit that referenced this issue May 14, 2018
@thakur-mohit
Copy link

thakur-mohit commented Dec 6, 2020

Hi . I am trying to reset password at runtime. Below is the application.yaml configuration. I have set registermbeans =true
What other code changes i need to make. kindly share some example.
spring:
datasource:
hikari:
connection-timeout: 70000
maximum-pool-size: 2
minimum-idle: 1
register-mbeans: true
url: jdbc:mysql://${DB_URL}:${DB_PORT}/${DB_NAME}?serverTimezone=UTC
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver

kollstrom pushed a commit to kollstrom/HikariCP that referenced this issue Feb 4, 2021
…for DriverDataSource-wrapped driver connections.
kollstrom pushed a commit to kollstrom/HikariCP that referenced this issue Feb 4, 2021
…for DriverDataSource-wrapped driver connections.
kollstrom pushed a commit to kollstrom/HikariCP that referenced this issue Feb 4, 2021
…for DriverDataSource-wrapped driver connections.
kollstrom pushed a commit to kollstrom/HikariCP that referenced this issue Feb 4, 2021
…for DriverDataSource-wrapped driver connections.
@yichuan-hpe
Copy link

Has this issue been fixed and released? which version?

@lfbayer
Copy link
Collaborator

lfbayer commented Dec 8, 2022

Fixed with "HikariCP-3.2.0". Clicking on the link (851e2d4) for the commit will show the tag/branch it is in.

@yichuan-hpe
Copy link

I tested against 3.4.5 and 4.0.3, still see the issue. I am using scala, but the code is doing the same as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants