From 456f2a82f216e1821ec35ebfd526c86c0200d9b2 Mon Sep 17 00:00:00 2001 From: zyyang Date: Fri, 15 Jan 2021 17:56:54 +0800 Subject: [PATCH] change --- .../java/com/taosdata/jdbc/TSDBResultSet.java | 2 +- .../java/com/taosdata/jdbc/TSDBStatement.java | 6 ------ .../MultiThreadsWithSameStatmentTest.java | 19 ++++++++++--------- 3 files changed, 11 insertions(+), 16 deletions(-) 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 84a3f58f46..a8a8b3ca87 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 @@ -39,7 +39,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -@SuppressWarnings("unused") public class TSDBResultSet implements ResultSet { private TSDBJNIConnector jniConnector = null; @@ -104,6 +103,7 @@ public class TSDBResultSet implements ResultSet { } public TSDBResultSet() { + } public TSDBResultSet(TSDBJNIConnector connector, long resultSetPointer) throws SQLException { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index 56e6d73a01..381f1d3622 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -68,12 +68,6 @@ public class TSDBStatement implements Statement { // TODO make sure it is not a update query pSql = this.connector.executeQuery(sql); - try { - TimeUnit.SECONDS.sleep(10); - } catch (InterruptedException e) { - e.printStackTrace(); - } - long resultSetPointer = this.connector.getResultSet(); if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) { this.connector.freeResultSet(pSql); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java index 3dc2f9680c..5cb76cc0cb 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java @@ -1,13 +1,11 @@ package com.taosdata.jdbc.cases; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import java.sql.*; import java.util.concurrent.TimeUnit; -import java.util.stream.IntStream; public class MultiThreadsWithSameStatmentTest { @@ -28,7 +26,7 @@ public class MultiThreadsWithSameStatmentTest { } } - public void release(){ + public void release() { try { stmt.close(); conn.close(); @@ -63,13 +61,16 @@ public class MultiThreadsWithSameStatmentTest { }); Thread t2 = new Thread(() -> { - try { - Service service = new Service(); - service.stmt.executeUpdate("insert into jdbctest.weather values(now,1)"); - service.release(); - } catch (SQLException e) { - e.printStackTrace(); + while (true) { + try { + Service service = new Service(); + service.stmt.executeUpdate("insert into jdbctest.weather values(now,1)"); + service.release(); + } catch (SQLException e) { + e.printStackTrace(); + } } + }); t1.start(); sleep(1000); -- GitLab