简体   繁体   中英

Properties file on HikariCP

I tried unsuccessfully configure hikaricp and I don't see error in the code please help.

public class DatabaseManager {

    private DatabaseClient[] databaseClients;
    private HikariDataSource hikariDataSource;

    public DatabaseManager(String absoluteFilePath) {
        final HikariConfig hikariConfig = new  HikariConfig(absoluteFilePath);
        this.hikariDataSource = new HikariDataSource(hikariConfig);
        System.out.println(hikariConfig.getUsername()); // null u-u
    }
}

Properties file:

## Database Settings
dataSourceClassName=org.mariadb.jdbc.MySQLDataSource
dataSource.user=root
dataSource.password=
dataSource.databaseName=imagine-db
dataSource.portNumber=3306
dataSource.serverName=localhost

You've set the username on the data source not on the config itself. This will still work fine but you can't access it using hikariConfig.getUsername() .

Try adding this to your properties file if you really need to access the user like that, although I suspect you don't.

username=root
password=

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM