|
@@ -13,13 +13,13 @@ import java.util.Properties;
|
|
|
@Configuration
|
|
|
public class TaosConfig {
|
|
|
|
|
|
- @Value("${taoscz.server_ip:123.60.219.66}")
|
|
|
+ @Value("${taoscz.server_ip:192.168.1.60}")
|
|
|
private String serverIp;
|
|
|
|
|
|
- @Value("${taoscz.server_port:6041}")
|
|
|
+ @Value("${taoscz.server_port:6030}")
|
|
|
private int serverPort;
|
|
|
|
|
|
- @Value("${taoscz.db_name:by_fdc}")
|
|
|
+ @Value("${taoscz.db_name:power_test}")
|
|
|
private String dbName;
|
|
|
|
|
|
@Value("${taoscz.user_name:root}")
|
|
@@ -37,20 +37,60 @@ public class TaosConfig {
|
|
|
@Value("${taoscz.driver_type:com.taosdata.jdbc.rs.RestfulDriver}")
|
|
|
private String driverType;
|
|
|
|
|
|
+ @Value("${taoscz.ai_stable_name:windturbineai}")
|
|
|
+ private String aiStableName;
|
|
|
+
|
|
|
+ @Value("${taoscz.di_stable_name:windturbinedi}")
|
|
|
+ private String diStableName;
|
|
|
+
|
|
|
private Connection connection = null;
|
|
|
+ private Connection createCon = null;
|
|
|
|
|
|
- public Connection getInstance() {
|
|
|
+ public Connection getInstance() throws Exception {
|
|
|
if (null == connection)
|
|
|
connection = getConnection();
|
|
|
|
|
|
return connection;
|
|
|
}
|
|
|
|
|
|
+ public Connection getCreateCon() throws Exception {
|
|
|
+ if (null == createCon || createCon.isClosed()){
|
|
|
+ Class.forName(driverType);
|
|
|
+ String jdbcUrl = "jdbc:TAOS-RS://" + serverIp + ":" + serverPort + "?user=" + userName + "&password=" + password;
|
|
|
+ if (driverType.equals("com.taosdata.jdbc.TSDBDriver"))
|
|
|
+ jdbcUrl = "jdbc:TAOS://" + serverIp + ":" + serverPort + "?user=" + userName + "&password=" + password;
|
|
|
+ Properties connProps = new Properties();
|
|
|
+ connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
|
|
|
+ connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
|
|
|
+ connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
|
|
|
+ createCon = DriverManager.getConnection(jdbcUrl, connProps);
|
|
|
+ }
|
|
|
+ return createCon;
|
|
|
+ }
|
|
|
|
|
|
- private Connection getConnection() {
|
|
|
+ public void closeCon() throws Exception {
|
|
|
+ if (null != createCon)
|
|
|
+ connection.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ private Connection getConnection2() throws Exception {
|
|
|
Connection connection = null;
|
|
|
|
|
|
- try {
|
|
|
+ Class.forName(driverType);
|
|
|
+ String jdbcUrl = "jdbc:TAOS-RS://" + serverIp + ":" + serverPort + "?user=" + userName + "&password=" + password;
|
|
|
+ if (driverType.equals("com.taosdata.jdbc.TSDBDriver"))
|
|
|
+ jdbcUrl = "jdbc:TAOS://" + serverIp + ":" + serverPort + "?user=" + userName + "&password=" + password;
|
|
|
+ Properties connProps = new Properties();
|
|
|
+ connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
|
|
|
+ connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
|
|
|
+ connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
|
|
|
+ connection = DriverManager.getConnection(jdbcUrl, connProps);
|
|
|
+
|
|
|
+ return connection;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Connection getConnection() throws Exception {
|
|
|
+ Connection connection = null;
|
|
|
|
|
|
Class.forName(driverType);
|
|
|
String jdbcUrl = "jdbc:TAOS-RS://" + serverIp + ":" + serverPort + "/" + dbName + "?user=" + userName + "&password=" + password;
|
|
@@ -61,17 +101,24 @@ public class TaosConfig {
|
|
|
connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
|
|
|
connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
|
|
|
connection = DriverManager.getConnection(jdbcUrl, connProps);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
return connection;
|
|
|
}
|
|
|
|
|
|
public String getTableName(String tagName) {
|
|
|
-
|
|
|
return dbName + "." + tagName;
|
|
|
}
|
|
|
|
|
|
+ public String getDbName() {
|
|
|
+ return dbName;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public String getAIStableName() {
|
|
|
+ return aiStableName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getDIStableName() {
|
|
|
+ return diStableName;
|
|
|
+ }
|
|
|
}
|