From 62ddd55b1512c480238db032da6bef473293efa3 Mon Sep 17 00:00:00 2001 From: zyyang Date: Sat, 6 Feb 2021 17:31:56 +0800 Subject: [PATCH] change --- .../java/com/taosdata/jdbc/SubscribeTest.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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 f5483616e1..7a40e9adb2 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 @@ -30,8 +30,9 @@ public class SubscribeTest { connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); statement = connection.createStatement(); - statement.executeUpdate("create database if not exists " + dbName); - statement.executeUpdate("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)"); + 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(); for (int i = 0; i < 2; i++) { ts += i; @@ -45,13 +46,12 @@ public class SubscribeTest { } @Test - public void subscribe() throws Exception { - TSDBSubscribe subscribe = null; + public void subscribe() { try { String rawSql = "select * from " + dbName + "." + tName + ";"; System.out.println(rawSql); - subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false); + TSDBSubscribe subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false); int a = 0; while (true) { @@ -69,12 +69,10 @@ public class SubscribeTest { break; } } + + subscribe.close(true); } catch (Exception e) { e.printStackTrace(); - } finally { - if (null != subscribe) { - subscribe.close(true); - } } }