提交 62ddd55b 编写于 作者: Z zyyang

change

上级 3ce4dd3d
...@@ -30,8 +30,9 @@ public class SubscribeTest { ...@@ -30,8 +30,9 @@ public class SubscribeTest {
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("create database if not exists " + dbName); statement.execute("drop database if exists " + dbName);
statement.executeUpdate("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)"); 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(); long ts = System.currentTimeMillis();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
ts += i; ts += i;
...@@ -45,13 +46,12 @@ public class SubscribeTest { ...@@ -45,13 +46,12 @@ public class SubscribeTest {
} }
@Test @Test
public void subscribe() throws Exception { public void subscribe() {
TSDBSubscribe subscribe = null;
try { try {
String rawSql = "select * from " + dbName + "." + tName + ";"; String rawSql = "select * from " + dbName + "." + tName + ";";
System.out.println(rawSql); System.out.println(rawSql);
subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false); TSDBSubscribe subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false);
int a = 0; int a = 0;
while (true) { while (true) {
...@@ -69,12 +69,10 @@ public class SubscribeTest { ...@@ -69,12 +69,10 @@ public class SubscribeTest {
break; break;
} }
} }
subscribe.close(true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (null != subscribe) {
subscribe.close(true);
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册