diff --git a/metadata-jdbc/pom.xml b/metadata-jdbc/pom.xml
index 9684ec497..a2d377518 100644
--- a/metadata-jdbc/pom.xml
+++ b/metadata-jdbc/pom.xml
@@ -47,9 +47,9 @@
- com.alibaba
- druid
- 1.2.20
+ com.zaxxer
+ HikariCP
+ 5.0.1
diff --git a/metadata-jdbc/src/main/java/com/automq/rocketmq/metadata/DruidDataSourceFactory.java b/metadata-jdbc/src/main/java/com/automq/rocketmq/metadata/DruidDataSourceFactory.java
deleted file mode 100644
index ea12877c8..000000000
--- a/metadata-jdbc/src/main/java/com/automq/rocketmq/metadata/DruidDataSourceFactory.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.automq.rocketmq.metadata;
-
-import com.alibaba.druid.pool.DruidDataSource;
-import java.sql.SQLException;
-import java.util.Properties;
-import javax.sql.DataSource;
-import org.apache.ibatis.datasource.pooled.PooledDataSourceFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DruidDataSourceFactory extends PooledDataSourceFactory {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DruidDataSourceFactory.class);
-
- private static DruidDataSource dataSource;
-
- @Override
- public void setProperties(Properties properties) {
- synchronized (DruidDataSourceFactory.class) {
- if (null == dataSource) {
- dataSource = new DruidDataSource();
- dataSource.setUrl(properties.getProperty("jdbcUrl"));
- dataSource.setUsername(properties.getProperty("username"));
- dataSource.setPassword(properties.getProperty("password"));
- try {
- dataSource.setFilters("stat,slf4j");
- } catch (SQLException e) {
- LOGGER.error("Failed to set stat filter", e);
- }
- dataSource.setMaxActive(20);
- dataSource.setInitialSize(5);
- dataSource.setMinIdle(1);
- dataSource.setMaxWait(6000);
-
- dataSource.setTimeBetweenEvictionRunsMillis(60000);
- dataSource.setMinEvictableIdleTimeMillis(300000);
- dataSource.setTestWhileIdle(true);
- dataSource.setTestOnBorrow(true);
- dataSource.setTestOnReturn(false);
-
- dataSource.setPoolPreparedStatements(true);
- dataSource.setMaxOpenPreparedStatements(20);
- dataSource.setAsyncInit(true);
-
- // Slow SQL
- dataSource.setConnectionProperties("druid.stat.slowSqlMillis=3000");
-
- // Detect Connection Leakage
- // https://github.com/alibaba/druid/wiki/%E8%BF%9E%E6%8E%A5%E6%B3%84%E6%BC%8F%E7%9B%91%E6%B5%8B
- dataSource.setRemoveAbandoned(true);
- // Unit: second
- dataSource.setRemoveAbandonedTimeout(1800);
- dataSource.setLogAbandoned(true);
-
- // log executable SQL
- // -Ddruid.log.stmt.executableSql=true
-
- try {
- dataSource.init();
- } catch (SQLException e) {
- LOGGER.error("Failed to init druid data source", e);
- throw new RuntimeException(e);
- }
- }
- }
- }
-
- @Override
- public DataSource getDataSource() {
- return dataSource;
- }
-}
diff --git a/metadata-jdbc/src/main/java/com/automq/rocketmq/metadata/HikariCPDataSourceFactory.java b/metadata-jdbc/src/main/java/com/automq/rocketmq/metadata/HikariCPDataSourceFactory.java
new file mode 100644
index 000000000..e43553000
--- /dev/null
+++ b/metadata-jdbc/src/main/java/com/automq/rocketmq/metadata/HikariCPDataSourceFactory.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.automq.rocketmq.metadata;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+import java.util.Properties;
+import javax.sql.DataSource;
+import org.apache.ibatis.datasource.pooled.PooledDataSourceFactory;
+
+public class HikariCPDataSourceFactory extends PooledDataSourceFactory {
+ private static HikariDataSource dataSource;
+
+ @Override
+ public void setProperties(Properties properties) {
+ synchronized (HikariCPDataSourceFactory.class) {
+ if (null == dataSource) {
+ HikariConfig config = new HikariConfig(properties);
+ config.setMaximumPoolSize(20);
+ config.setAutoCommit(false);
+ dataSource = new HikariDataSource(config);
+ }
+ }
+ }
+
+ @Override
+ public DataSource getDataSource() {
+ return dataSource;
+ }
+}
diff --git a/metadata-jdbc/src/main/resources/database/mybatis-config.xml b/metadata-jdbc/src/main/resources/database/mybatis-config.xml
index ee8033fcc..30b0e0f7e 100644
--- a/metadata-jdbc/src/main/resources/database/mybatis-config.xml
+++ b/metadata-jdbc/src/main/resources/database/mybatis-config.xml
@@ -57,7 +57,7 @@
-
+