未验证 提交 01ede706 编写于 作者: H huili 提交者: GitHub

Merge pull request #5046 from taosdata/hotfix/TD-2597

[TD-2597]<fix>: fix Druid and HikariCP configurations errors
......@@ -10,20 +10,18 @@ public class DruidPoolBuilder {
final String url = "jdbc:TAOS://" + host + ":6030";
DruidDataSource dataSource = new DruidDataSource();
// jdbc properties
dataSource.setUrl(url);
dataSource.setDriverClassName("com.taosdata.jdbc.TSDBDriver");
dataSource.setUsername("root");
dataSource.setPassword("taosdata");
//初始连接数,默认0
dataSource.setInitialSize(poolSize);
//最大连接数,默认8
dataSource.setMaxActive(poolSize);
//最小闲置数
dataSource.setMinIdle(poolSize);
//获取连接的最大等待时间,单位毫秒
dataSource.setMaxWait(2000);
// pool configurations
dataSource.setInitialSize(poolSize);//初始连接数,默认0
dataSource.setMinIdle(poolSize);//最小闲置数
dataSource.setMaxActive(poolSize);//最大连接数,默认8
dataSource.setMaxWait(30000);//获取连接的最大等待时间,单位毫秒
dataSource.setValidationQuery("select server_status()");
return dataSource;
}
......
......@@ -9,13 +9,18 @@ public class HikariCpBuilder {
public static DataSource getDataSource(String host, int poolSize) {
HikariConfig config = new HikariConfig();
// jdbc properties
config.setDriverClassName("com.taosdata.jdbc.TSDBDriver");
config.setJdbcUrl("jdbc:TAOS://" + host + ":6030");
config.setUsername("root");
config.setPassword("taosdata");
// pool configurations
config.setMinimumIdle(3); //minimum number of idle connection
config.setMaximumPoolSize(10); //maximum number of connection in the pool
config.setConnectionTimeout(30000); //maximum wait milliseconds for get connection from pool
config.setIdleTimeout(0); // max idle time for recycle idle connection
config.setConnectionTestQuery("select server_status()"); //validation query
config.setMaximumPoolSize(poolSize);
config.setMinimumIdle(poolSize);
HikariDataSource ds = new HikariDataSource(config);
return ds;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册