From 6ef291960dfdc31dc5fc475e9f11b2c1de164ac3 Mon Sep 17 00:00:00 2001 From: huolibo Date: Thu, 28 Apr 2022 12:01:14 +0800 Subject: [PATCH] docs(driver): convert description --- .../main/java/com/taos/example/SubscribeDemo.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java b/docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java index 410897847c..d82d03b9de 100644 --- a/docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java +++ b/docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java @@ -27,11 +27,14 @@ public class SubscribeDemo { properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); String jdbcUrl = "jdbc:TAOS://127.0.0.1:6030/power?user=root&password=taosdata"; connection = DriverManager.getConnection(jdbcUrl, properties); - subscribe = ((TSDBConnection) connection).subscribe(topic, sql, true); // 创建订阅 + // create subscribe + subscribe = ((TSDBConnection) connection).subscribe(topic, sql, true); int count = 0; while (count < 10) { - TimeUnit.SECONDS.sleep(1); // 等待1秒,避免频繁调用 consume,给服务端造成压力 - TSDBResultSet resultSet = subscribe.consume(); // 消费数据 + // wait 1 second to avoid frequent calls to consume + TimeUnit.SECONDS.sleep(1); + // consume + TSDBResultSet resultSet = subscribe.consume(); if (resultSet == null) { continue; } @@ -50,7 +53,8 @@ public class SubscribeDemo { } finally { try { if (null != subscribe) - subscribe.close(true); // 关闭订阅 + // close subscribe + subscribe.close(true); if (connection != null) connection.close(); } catch (SQLException throwable) { -- GitLab