|
@@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
import javax.sql.DataSource;
|
|
import java.sql.Connection;
|
|
import java.sql.Connection;
|
|
|
|
+import java.sql.DriverManager;
|
|
import java.sql.SQLException;
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
|
|
@@ -40,17 +41,25 @@ public class TaosConfiguration {
|
|
private static DataSource dataSource = null;
|
|
private static DataSource dataSource = null;
|
|
|
|
|
|
|
|
|
|
- public Connection getConnect() {
|
|
|
|
- if (null == dataSource) {
|
|
|
|
- dataSource = getDataSource();
|
|
|
|
- }
|
|
|
|
|
|
+ public Connection getConnect() throws SQLException {
|
|
|
|
+// String jdbcUrl = "jdbc:TAOS-RS://td1:6041?user=root&password=taosdata";
|
|
|
|
|
|
|
|
+ final String jdbcUrl = "jdbc:TAOS-RS://" + serverIp + ":" + serverPort+"/"+database+"?user="+userName+"&password="+password;
|
|
try {
|
|
try {
|
|
- return dataSource.getConnection();
|
|
|
|
|
|
+ return DriverManager.getConnection(jdbcUrl);
|
|
} catch (SQLException e) {
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// if (null == dataSource) {
|
|
|
|
+// dataSource = getDataSource();
|
|
|
|
+// }
|
|
|
|
+// try {
|
|
|
|
+// return dataSource.getConnection();
|
|
|
|
+// } catch (SQLException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -78,6 +87,8 @@ public class TaosConfiguration {
|
|
private DataSource getDataSource() {
|
|
private DataSource getDataSource() {
|
|
final String url = "jdbc:TAOS://" + serverIp + ":" + serverPort+"/"+database;
|
|
final String url = "jdbc:TAOS://" + serverIp + ":" + serverPort+"/"+database;
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
DruidDataSource dataSource = new DruidDataSource();
|
|
DruidDataSource dataSource = new DruidDataSource();
|
|
// jdbc properties
|
|
// jdbc properties
|
|
dataSource.setDriverClassName("com.taosdata.jdbc.TSDBDriver");
|
|
dataSource.setDriverClassName("com.taosdata.jdbc.TSDBDriver");
|