diff --git a/cmake/install.inc b/cmake/install.inc
index 9e325531d51c7ebb315fb01ccbd0cbb06ffcd5d5..f8b3b7c3c62c16df537a941d7f14ccb74bc64217 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.28-dist.jar DESTINATION connector/jdbc)
+ INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.29.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 de4b8f6bfb92d2de0810dab50c70452f7d47b7a8..61e976cb184d3240bdc8917a5b2e5f3182d55fcc 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.28-dist.jar ${LIBRARY_OUTPUT_PATH}
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.29.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 a31796ffdeeb4b76835e4b04d40720dda149fddc..968a9bf470ddde1996467467fa24cfd2fbf355e0 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.28
+ 2.0.29
jar
JDBCDriver
diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml
index 3400a82e73640c79f6157fafd2bbe8c7520145dd..d94d28d9fa3092932f1c233a689767b859b7f0da 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.28
+ 2.0.29
jar
JDBCDriver
https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
index 5e3ffffa4fe7326b8c1e89ac91a37e95c346784f..7f0cf7de8d1182d29b190ab7e6bf4379876ab778 100755
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
@@ -32,7 +32,7 @@ public class TSDBJNIConnector {
// Connection pointer used in C
private long taos = TSDBConstants.JNI_NULL_POINTER;
// result set status in current connection
- private boolean isResultsetClosed = true;
+ private boolean isResultsetClosed;
private int affectedRows = -1;
static {
@@ -135,6 +135,7 @@ public class TSDBJNIConnector {
// Try retrieving result set for the executed SQL using the current connection pointer.
pSql = this.getResultSetImp(this.taos, pSql);
+ // if pSql == 0L that means resultset is closed
isResultsetClosed = (pSql == TSDBConstants.JNI_NULL_POINTER);
return pSql;
@@ -172,16 +173,7 @@ public class TSDBJNIConnector {
* Free resultset operation from C to release resultset pointer by JNI
*/
public int freeResultSet(long pSql) {
- int res = TSDBConstants.JNI_SUCCESS;
-// if (result != taosResultSetPointer && taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
-// throw new RuntimeException("Invalid result set pointer");
-// }
-
-// if (taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
- res = this.freeResultSetImp(this.taos, pSql);
-// taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
-// }
-
+ int res = this.freeResultSetImp(this.taos, pSql);
isResultsetClosed = true;
return res;
}
@@ -199,7 +191,6 @@ public class TSDBJNIConnector {
// }
// return resCode;
// }
-
private native int freeResultSetImp(long connection, long result);
/**
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
index 2576a25f0d40e15efbb958706f672a40fbd2ee2e..aba29d602b8900d3bedee49ee94e7d226b3bd1f0 100644
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
+++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
@@ -109,6 +109,8 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
public void close() throws SQLException {
if (isClosed)
return;
+ if (this.statement == null)
+ return;
if (this.jniConnector != null) {
int code = this.jniConnector.freeResultSet(this.resultSetPointer);
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
@@ -461,12 +463,13 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
}
public boolean isClosed() throws SQLException {
- if (isClosed)
- return true;
- if (jniConnector != null) {
- isClosed = jniConnector.isResultsetClosed();
- }
return isClosed;
+// if (isClosed)
+// return true;
+// if (jniConnector != null) {
+// isClosed = jniConnector.isResultsetClosed();
+// }
+// return isClosed;
}
public String getNString(int columnIndex) throws SQLException {
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
index 3a223ed981a7f465386319c3a671782c92bf334f..24c73fdd5c14af41039eb12a7713216166312a09 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
@@ -1,6 +1,7 @@
package com.taosdata.jdbc;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -19,6 +20,7 @@ public class SubscribeTest {
String tName = "t0";
String host = "127.0.0.1";
String topic = "test";
+ private long ts;
@Test
public void subscribe() {
@@ -27,26 +29,40 @@ public class SubscribeTest {
TSDBConnection conn = connection.unwrap(TSDBConnection.class);
TSDBSubscribe subscribe = conn.subscribe(topic, rawSql, false);
- int a = 0;
- while (true) {
- TimeUnit.MILLISECONDS.sleep(1000);
+ for (int j = 0; j < 10; j++) {
+ TimeUnit.SECONDS.sleep(1);
TSDBResultSet resSet = subscribe.consume();
+
+ int rowCnt = 0;
while (resSet.next()) {
- for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) {
- System.out.printf(i + ": " + resSet.getString(i) + "\t");
+ if (rowCnt == 0) {
+ long cur_ts = resSet.getTimestamp(1).getTime();
+ int k = resSet.getInt(2);
+ int v = resSet.getInt(3);
+ Assert.assertEquals(ts, cur_ts);
+ Assert.assertEquals(100, k);
+ Assert.assertEquals(1, v);
}
- System.out.println("\n======" + a + "==========");
- }
- a++;
- if (a >= 2) {
- break;
+ if (rowCnt == 1) {
+ long cur_ts = resSet.getTimestamp(1).getTime();
+ int k = resSet.getInt(2);
+ int v = resSet.getInt(3);
+ Assert.assertEquals(ts + 1, cur_ts);
+ Assert.assertEquals(101, k);
+ Assert.assertEquals(2, v);
+
+ }
+ rowCnt++;
}
+ if (j == 0)
+ Assert.assertEquals(2, rowCnt);
resSet.close();
}
-
subscribe.close(true);
- } catch (Exception e) {
- e.printStackTrace();
+
+
+ } catch (SQLException | InterruptedException throwables) {
+ throwables.printStackTrace();
}
}
@@ -62,7 +78,7 @@ public class SubscribeTest {
statement.execute("drop database if exists " + dbName);
statement.execute("create database if not exists " + dbName);
statement.execute("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)");
- long ts = System.currentTimeMillis();
+ ts = System.currentTimeMillis();
statement.executeUpdate("insert into " + dbName + "." + tName + " values (" + ts + ", 100, 1)");
statement.executeUpdate("insert into " + dbName + "." + tName + " values (" + (ts + 1) + ", 101, 2)");
}