diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index aecb969312432..3217d36b5b359 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -48,6 +48,7 @@ 1. SQL Binder: Support load data and load xml sql bind and add test case - [#34177](https://github.com/apache/shardingsphere/pull/34177) 1. Transaction: Support savepoint/release savepoint TCL statements in jdbc adapter -[#34173](https://github.com/apache/shardingsphere/pull/34173) 1. Kernel: Add WithAvailable interface and encrypt with, combine, insert select support checker - [#34175](https://github.com/apache/shardingsphere/pull/34175) +1. Mode: Support modifying Hikari-CP configurations via props in standalone mode [#34185](https://github.com/apache/shardingsphere/pull/34185) ### Bug Fixes diff --git a/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java b/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java index 098b9e965725c..25ddab133d17e 100644 --- a/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java +++ b/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java @@ -18,7 +18,9 @@ package org.apache.shardingsphere.mode.repository.standalone.jdbc; import com.google.common.base.Strings; +import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; +import com.zaxxer.hikari.util.PropertyElf; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository; @@ -58,11 +60,21 @@ public final class JDBCRepository implements StandalonePersistRepository { public void init(final Properties props) { JDBCRepositoryProperties jdbcRepositoryProps = new JDBCRepositoryProperties(props); repositorySQL = JDBCRepositorySQLLoader.load(jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.PROVIDER)); - dataSource = new HikariDataSource(); - dataSource.setDriverClassName(repositorySQL.getDriverClassName()); - dataSource.setJdbcUrl(jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.JDBC_URL)); - dataSource.setUsername(jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.USERNAME)); - dataSource.setPassword(jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.PASSWORD)); + + Properties hikariProperties = PropertyElf.copyProperties(props); + hikariProperties.remove(JDBCRepositoryPropertyKey.PROVIDER.getKey()); + hikariProperties.remove(JDBCRepositoryPropertyKey.JDBC_URL.getKey()); + hikariProperties.remove(JDBCRepositoryPropertyKey.USERNAME.getKey()); + hikariProperties.remove(JDBCRepositoryPropertyKey.PASSWORD.getKey()); + + HikariConfig hikariConfig = new HikariConfig(hikariProperties); + hikariConfig.setDriverClassName(repositorySQL.getDriverClassName()); + hikariConfig.setJdbcUrl(jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.JDBC_URL)); + hikariConfig.setUsername(jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.USERNAME)); + hikariConfig.setPassword(jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.PASSWORD)); + + dataSource = new HikariDataSource(hikariConfig); + try ( Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement()) {