fix: adapter 3.0 (#20391)
This commit is contained in:
parent
1bb976a545
commit
d632f035a2
|
@ -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)");
|
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 {
|
public long count() throws SQLException {
|
||||||
if (!stmt.isClosed()) {
|
try (ResultSet result = stmt.executeQuery("SELECT count(*) from test.meters")) {
|
||||||
ResultSet result = stmt.executeQuery("SELECT count(*) from test.meters");
|
|
||||||
result.next();
|
result.next();
|
||||||
return result.getLong(1);
|
return result.getLong(1);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public long getTableCount() throws SQLException {
|
||||||
* show test.stables;
|
try (ResultSet result = stmt.executeQuery("select count(*) from information_schema.ins_tables where db_name = 'test';")) {
|
||||||
*
|
|
||||||
* 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");
|
|
||||||
result.next();
|
result.next();
|
||||||
return result.getLong(5);
|
return result.getLong(1);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -42,7 +42,7 @@ public class SQLWriter {
|
||||||
/**
|
/**
|
||||||
* Maximum SQL length.
|
* Maximum SQL length.
|
||||||
*/
|
*/
|
||||||
private int maxSQLLength;
|
private int maxSQLLength = 800_000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map from table name to column values. For example:
|
* Map from table name to column values. For example:
|
||||||
|
@ -81,14 +81,6 @@ public class SQLWriter {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
stmt = conn.createStatement();
|
stmt = conn.createStatement();
|
||||||
stmt.execute("use test");
|
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) {
|
} catch (SQLException e) {
|
||||||
// convert to error code defined in taoserror.h
|
// convert to error code defined in taoserror.h
|
||||||
int errorCode = e.getErrorCode() & 0xffff;
|
int errorCode = e.getErrorCode() & 0xffff;
|
||||||
if (errorCode == 0x362 || errorCode == 0x218) {
|
if (errorCode == 0x2603) {
|
||||||
// Table does not exist
|
// Table does not exist
|
||||||
createTables();
|
createTables();
|
||||||
executeSQL(sql);
|
executeSQL(sql);
|
||||||
|
|
Loading…
Reference in New Issue