diff --git a/cmake/install.inc b/cmake/install.inc
index b0e5c71022c7c30fefd79ed62830db6afeb953f2..a5b01f43cb7e8a302a9cf2d6d7ef48ddb8ed944e 100755
--- a/cmake/install.inc
+++ b/cmake/install.inc
@@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED)
- INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.16-dist.jar DESTINATION connector/jdbc)
+ INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.17-dist.jar DESTINATION connector/jdbc)
ENDIF ()
ELSEIF (TD_DARWIN)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt
index 7097e9bc5add0b944e1df1911972422cdcbd1c58..b64161e2e4fd6fc00abb659118cfdcd50dfcf0a8 100644
--- a/src/connector/jdbc/CMakeLists.txt
+++ b/src/connector/jdbc/CMakeLists.txt
@@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME}
POST_BUILD
COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.16-dist.jar ${LIBRARY_OUTPUT_PATH}
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.17-dist.jar ${LIBRARY_OUTPUT_PATH}
COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
COMMENT "build jdbc driver")
ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME})
diff --git a/src/connector/jdbc/deploy-pom.xml b/src/connector/jdbc/deploy-pom.xml
index 5aa60c0df9311a18d5c849f125b24f6764579bdd..1f03c3c6fe5e1d5f1d7d12a0df7babb6edb789f1 100755
--- a/src/connector/jdbc/deploy-pom.xml
+++ b/src/connector/jdbc/deploy-pom.xml
@@ -5,7 +5,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.16
+ 2.0.17
jar
JDBCDriver
diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml
index d18d86258a41ef4420863eddc47c20b24407f49a..5481056763e17e2058521c437c801e2a35c58f41 100755
--- a/src/connector/jdbc/pom.xml
+++ b/src/connector/jdbc/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.16
+ 2.0.17
jar
JDBCDriver
https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java
index 3a01e2e09297d6af1405c63200e2ba91b3fa99a2..3d7e6034ddf58761ca9981a3ce2a82ed372d6daa 100644
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java
+++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java
@@ -24,7 +24,6 @@ import java.sql.SQLException;
*/
public class CatalogResultSet extends TSDBResultSetWrapper {
-
public CatalogResultSet(ResultSet resultSet) {
super.setOriginalResultSet(resultSet);
}
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetColumnsResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetColumnsResultSet.java
deleted file mode 100644
index e15415e037948dd7ec757bcdeee03d14a0d588fb..0000000000000000000000000000000000000000
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetColumnsResultSet.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *****************************************************************************/
-package com.taosdata.jdbc;
-
-import java.sql.ResultSet;
-
-/*
- * TDengine only supports a subset of the standard SQL, thus this implemetation of the
- * standard JDBC API contains more or less some adjustments customized for certain
- * compatibility needs.
- */
-public class GetColumnsResultSet extends TSDBResultSetWrapper {
- private String catalog;
- private String schemaPattern;
- private String tableNamePattern;
- private String columnNamePattern;
-
- public GetColumnsResultSet(ResultSet resultSet, String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) {
- super.setOriginalResultSet(resultSet);
- this.catalog = catalog;
- this.schemaPattern = schemaPattern;
- this.tableNamePattern = tableNamePattern;
- this.columnNamePattern = columnNamePattern;
- }
-
- @Override
- public String getString(int columnIndex) {
- switch (columnIndex) {
- case 1:
- return catalog;
- case 2:
- return null;
- case 3:
- return tableNamePattern;
- default:
- return null;
- }
- }
-}
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
index 02556f6a73c9bc623c6c7a2c05ffea680596ac9a..53f3714555476317662be1397c3d911168d824c5 100644
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
+++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
@@ -620,6 +620,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
ResultSet tables = stmt.executeQuery("show tables");
while (tables.next()) {
TSDBResultSetRowData rowData = new TSDBResultSetRowData(10);
+ rowData.setString(0, dbname);
rowData.setString(2, tables.getString("table_name"));
rowData.setString(3, "TABLE");
rowData.setString(4, "");
@@ -629,6 +630,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
ResultSet stables = stmt.executeQuery("show stables");
while (stables.next()) {
TSDBResultSetRowData rowData = new TSDBResultSetRowData(10);
+ rowData.setString(0, dbname);
rowData.setString(2, stables.getString("name"));
rowData.setString(3, "TABLE");
rowData.setString(4, "STABLE");
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBParameterMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBParameterMetaData.java
deleted file mode 100644
index d9227523d4ac623d23d85be6376a1530ca606751..0000000000000000000000000000000000000000
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBParameterMetaData.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *****************************************************************************/
-package com.taosdata.jdbc;
-
-import java.sql.ParameterMetaData;
-import java.sql.SQLException;
-
-public class TSDBParameterMetaData implements ParameterMetaData {
- @Override
- public int getParameterCount() throws SQLException {
- return 0;
- }
-
- @Override
- public int isNullable(int param) throws SQLException {
- return 0;
- }
-
- @Override
- public boolean isSigned(int param) throws SQLException {
- return false;
- }
-
- @Override
- public int getPrecision(int param) throws SQLException {
- return 0;
- }
-
- @Override
- public int getScale(int param) throws SQLException {
- return 0;
- }
-
- @Override
- public int getParameterType(int param) throws SQLException {
- return 0;
- }
-
- @Override
- public String getParameterTypeName(int param) throws SQLException {
- return null;
- }
-
- @Override
- public String getParameterClassName(int param) throws SQLException {
- return null;
- }
-
- @Override
- public int getParameterMode(int param) throws SQLException {
- return 0;
- }
-
- @Override
- public T unwrap(Class iface) throws SQLException {
- return null;
- }
-
- @Override
- public boolean isWrapperFor(Class> iface) throws SQLException {
- return false;
- }
-}
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribeCallBack.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribeCallBack.java
deleted file mode 100644
index c1b9b02fa85f8e2197f41d75f8f0c25b3f4c416c..0000000000000000000000000000000000000000
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribeCallBack.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *****************************************************************************/
-package com.taosdata.jdbc;
-
-public interface TSDBSubscribeCallBack {
- void invoke(TSDBResultSet resultSet);
-}
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
index cb6ff369f2b43f7cfae63fcc57701d692d3d803b..fca8847114529280bf70d4bf8e56508a572ef7e4 100644
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
+++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
@@ -44,6 +44,8 @@ public class RestfulDriver extends AbstractTaosDriver {
String result = HttpClientPoolUtil.execute(loginUrl);
JSONObject jsonResult = JSON.parseObject(result);
String status = jsonResult.getString("status");
+ String token = jsonResult.getString("desc");
+ HttpClientPoolUtil.token = token;
if (!status.equals("succ")) {
throw new SQLException(jsonResult.getString("desc"));
}
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java
index 23e8796980ac419635ef6953deff1033d158962e..9b1681ff948dc9257e7b775d947c598d9dc60378 100644
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java
+++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java
@@ -23,6 +23,7 @@ import java.nio.charset.Charset;
public class HttpClientPoolUtil {
public static PoolingHttpClientConnectionManager cm = null;
public static CloseableHttpClient httpClient = null;
+ public static String token = "cm9vdDp0YW9zZGF0YQ==";
/**
* 默认content 类型
*/
@@ -61,9 +62,7 @@ public class HttpClientPoolUtil {
try {
return Long.parseLong(value) * 1000;
} catch (Exception e) {
- new Exception(
- "format KeepAlive timeout exception, exception:" + e.toString())
- .printStackTrace();
+ new Exception("format KeepAlive timeout exception, exception:" + e.toString()).printStackTrace();
}
}
}
@@ -96,7 +95,7 @@ public class HttpClientPoolUtil {
initPools();
}
method = (HttpEntityEnclosingRequestBase) getRequest(uri, HttpPost.METHOD_NAME, DEFAULT_CONTENT_TYPE, 0);
- method.setHeader("Authorization", "Basic cm9vdDp0YW9zZGF0YQ==");
+ method.setHeader("Authorization", "Taosd " + token);
method.setHeader("Content-Type", "text/plain");
method.setEntity(new StringEntity(data, Charset.forName("UTF-8")));
HttpContext context = HttpClientContext.create();
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
index 04e9ffab31b2a32e7e1cfa6b8a606fc26e6e6e2e..77223b40fae75a137d9ba5579d0d8de2815edc32 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
@@ -642,6 +642,7 @@ public class TSDBDatabaseMetaDataTest {
ResultSet tables = metaData.getTables("log", "", null, null);
ResultSetMetaData metaData = tables.getMetaData();
while (tables.next()) {
+ System.out.print(metaData.getColumnLabel(1) + ":" + tables.getString(1) + "\t");
System.out.print(metaData.getColumnLabel(3) + ":" + tables.getString(3) + "\t");
System.out.print(metaData.getColumnLabel(4) + ":" + tables.getString(4) + "\t");
System.out.print(metaData.getColumnLabel(5) + ":" + tables.getString(5) + "\n");
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..e1e68766b99f4711114b0bd81b4e345d7d3c245e
--- /dev/null
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java
@@ -0,0 +1,66 @@
+package com.taosdata.jdbc.rs;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.sql.*;
+
+public class AuthenticationTest {
+
+ // private static final String host = "127.0.0.1";
+ private static final String host = "master";
+ private static final String user = "root";
+ private static final String password = "123456";
+ private Connection conn;
+
+ @Test
+ public void test() {
+ // change password
+ try {
+ conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/restful_test?user=" + user + "&password=taosdata");
+ Statement stmt = conn.createStatement();
+ stmt.execute("alter user " + user + " pass '" + password + "'");
+ stmt.close();
+ conn.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ // use new to login and execute query
+ try {
+ conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/restful_test?user=" + user + "&password=" + password);
+ Statement stmt = conn.createStatement();
+ stmt.execute("show databases");
+ ResultSet rs = stmt.getResultSet();
+ ResultSetMetaData meta = rs.getMetaData();
+ while (rs.next()) {
+ for (int i = 1; i <= meta.getColumnCount(); i++) {
+ System.out.print(meta.getColumnLabel(i) + ":" + rs.getString(i) + "\t");
+ }
+ System.out.println();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ // change password back
+ try {
+ conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/restful_test?user=" + user + "&password=" + password);
+ Statement stmt = conn.createStatement();
+ stmt.execute("alter user " + user + " pass 'taosdata'");
+ stmt.close();
+ conn.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Before
+ public void before() {
+ try {
+ Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
index d07a6a21796fc2ea7927c04fd0cf5a37e9a49988..3416436615471280d5fc4faf631121da350585bf 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
@@ -6,6 +6,7 @@ import org.junit.Test;
import java.sql.*;
public class RestfulDriverTest {
+ private static final String host = "master";
@Test
public void connect() {
@@ -15,9 +16,9 @@ public class RestfulDriverTest {
@Test
public void acceptsURL() throws SQLException {
Driver driver = new RestfulDriver();
- boolean isAccept = driver.acceptsURL("jdbc:TAOS-RS://master:6041");
+ boolean isAccept = driver.acceptsURL("jdbc:TAOS-RS://" + host + ":6041");
Assert.assertTrue(isAccept);
- isAccept = driver.acceptsURL("jdbc:TAOS://master:6041");
+ isAccept = driver.acceptsURL("jdbc:TAOS://" + host + ":6041");
Assert.assertFalse(isAccept);
}
@@ -26,6 +27,9 @@ public class RestfulDriverTest {
Driver driver = new RestfulDriver();
final String url = "";
DriverPropertyInfo[] propertyInfo = driver.getPropertyInfo(url, null);
+ for (DriverPropertyInfo prop : propertyInfo) {
+ System.out.println(prop);
+ }
}
@Test
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
index 0af6b91532b63773510e10806d8f1e744ffe966e..573ad027b8b6375cd875e842891f750bfc8c2ecf 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
@@ -1,6 +1,5 @@
package com.taosdata.jdbc.rs;
-
import org.junit.*;
import org.junit.runners.MethodSorters;
@@ -10,12 +9,13 @@ import java.util.Random;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestfulJDBCTest {
+ private static final String host = "master";
private Connection connection;
@Before
public void before() throws ClassNotFoundException, SQLException {
Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
- connection = DriverManager.getConnection("jdbc:TAOS-RS://master:6041/restful_test?user=root&password=taosdata");
+ connection = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/restful_test?user=root&password=taosdata");
}
@After
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
index ce84f967d09e2217bac90cc7a3f59bf4f50b2a15..c38958c6ceb50af5d3925003f34e5cc16c272b97 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
@@ -21,4 +21,5 @@ public class SqlSyntaxValidatorTest {
Assert.assertTrue(SqlSyntaxValidator.isUseSql("drop database test"));
Assert.assertTrue(SqlSyntaxValidator.isUseSql("drop database if exist test"));
}
+
}
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/pom.xml b/tests/examples/JDBC/taosdemo/pom.xml
index 72adbd0fa3664572e1b725f1769cad031bc58c10..15f868a117238956e79d58222809140e2a098144 100644
--- a/tests/examples/JDBC/taosdemo/pom.xml
+++ b/tests/examples/JDBC/taosdemo/pom.xml
@@ -67,9 +67,9 @@
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.16
-
-
+ 2.0.17
+
+