提交 cb75a3e2 编写于 作者: Z zyyang

change

上级 503b420e
package com.taosdata.taosdemo.components;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
@Component
public class DataSourceFactory {
private static DataSource instance;
public static DataSource getInstance(String host, int port, String user, String password) {
if (instance == null) {
synchronized (DataSourceFactory.class) {
if (instance == null) {
HikariConfig config = new HikariConfig();
config.setDriverClassName("com.taosdata.jdbc.TSDBDriver");
config.setJdbcUrl("jdbc:TAOS://" + host + ":" + port + "/?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8");
config.setUsername(user);
config.setPassword(password);
config.setMaxLifetime(0);
config.setMaximumPoolSize(500);
config.setMinimumIdle(100);
instance = new HikariDataSource(config);
}
}
}
return instance;
}
}
......@@ -10,12 +10,12 @@ import com.taosdata.taosdemo.service.SuperTableService;
import com.taosdata.taosdemo.service.data.SubTableValueGenerator;
import com.taosdata.taosdemo.service.data.SuperTableMetaGenerator;
import com.taosdata.taosdemo.utils.JdbcTaosdemoConfig;
import com.taosdata.taosdemo.utils.TimeStampUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.time.Duration;
import java.time.Instant;
import java.util.*;
......@@ -37,6 +37,7 @@ public class TaosDemoCommandLineRunner implements CommandLineRunner {
// private List<SubTableValue> subTableValueList;
// private List<List<SubTableValue>> dataList;
@Override
public void run(String... args) throws Exception {
// 读配置参数
......@@ -46,6 +47,9 @@ public class TaosDemoCommandLineRunner implements CommandLineRunner {
JdbcTaosdemoConfig.printHelp();
System.exit(0);
}
DataSource dataSource = DataSourceFactory.getInstance(config.host, config.port, config.user, config.password);
// 准备数据
prepareMetaData(config);
// 超级表的meta
......
#spring.datasource.url=jdbc:mysql://master:3306/?useSSL=false&useUnicode=true&characterEncoding=UTF-8
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#spring.datasource.username=root
#spring.datasource.password=123456
spring.datasource.url=jdbc:TAOS://:/?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8
spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver
spring.datasource.username=root
spring.datasource.password=taosdata
#spring.datasource.url=jdbc:TAOS-RS://:/?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8
#spring.datasource.driver-class-name=com.taosdata.jdbc.rs.RestfulDriver
#spring.datasource.username=root
#spring.datasource.password=taosdata
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.max-lifetime=600000
logging.level.com.taosdata.taosdemo.mapper=error
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册