diff --git a/docs/examples/java/src/main/java/com/taos/example/highvolume/DataBaseMonitor.java b/docs/examples/java/src/main/java/com/taos/example/highvolume/DataBaseMonitor.java index 04b149a4b9..8678f65231 100644 --- a/docs/examples/java/src/main/java/com/taos/example/highvolume/DataBaseMonitor.java +++ b/docs/examples/java/src/main/java/com/taos/example/highvolume/DataBaseMonitor.java @@ -36,28 +36,17 @@ public class DataBaseMonitor { stmt.execute("CREATE STABLE test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"); } - public Long count() throws SQLException { - if (!stmt.isClosed()) { - ResultSet result = stmt.executeQuery("SELECT count(*) from test.meters"); + public long count() throws SQLException { + try (ResultSet result = stmt.executeQuery("SELECT count(*) from test.meters")) { result.next(); return result.getLong(1); } - return null; } - /** - * show test.stables; - * - * name | created_time | columns | tags | tables | - * ============================================================================================ - * meters | 2022-07-20 08:39:30.902 | 4 | 2 | 620000 | - */ - public Long getTableCount() throws SQLException { - if (!stmt.isClosed()) { - ResultSet result = stmt.executeQuery("show test.stables"); + public long getTableCount() throws SQLException { + try (ResultSet result = stmt.executeQuery("select count(*) from information_schema.ins_tables where db_name = 'test';")) { result.next(); - return result.getLong(5); + return result.getLong(1); } - return null; } } \ No newline at end of file diff --git a/docs/examples/java/src/main/java/com/taos/example/highvolume/SQLWriter.java b/docs/examples/java/src/main/java/com/taos/example/highvolume/SQLWriter.java index c2989acdbe..dc820f161c 100644 --- a/docs/examples/java/src/main/java/com/taos/example/highvolume/SQLWriter.java +++ b/docs/examples/java/src/main/java/com/taos/example/highvolume/SQLWriter.java @@ -42,7 +42,7 @@ public class SQLWriter { /** * Maximum SQL length. */ - private int maxSQLLength; + private int maxSQLLength = 800_000; /** * Map from table name to column values. For example: @@ -81,14 +81,6 @@ public class SQLWriter { conn = getConnection(); stmt = conn.createStatement(); stmt.execute("use test"); - ResultSet rs = stmt.executeQuery("show variables"); - while (rs.next()) { - String configName = rs.getString(1); - if ("maxSQLLength".equals(configName)) { - maxSQLLength = Integer.parseInt(rs.getString(2)); - logger.info("maxSQLLength={}", maxSQLLength); - } - } } /** @@ -149,7 +141,7 @@ public class SQLWriter { } catch (SQLException e) { // convert to error code defined in taoserror.h int errorCode = e.getErrorCode() & 0xffff; - if (errorCode == 0x362 || errorCode == 0x218) { + if (errorCode == 0x2603) { // Table does not exist createTables(); executeSQL(sql);