'question on JDBC TSDBPreparedStatement with TDengine

When using JDBC PreparedStatement::addBatch to add a SQL, the double quotes in SQL can be falsely omitted.

preparing data: create a stable create stable stb (ts timestamp, col int) tags (nchar_tag nchar(8)); create a table using PreparedStatement:

code is following:

String sql = "create table tb using stb (nchar_tag) tags ('\"abc\"')";
Connection conn = getConn();
PreparedStatement pstmt = conn.prepareStatement(sql);
pStmt.addBatch();
pStmt.executeBatch();
conn.close();

Thene to query show

create table tb and get CREATE TABLE tb USING stb TAGS ("abc")

I think the tag should be "abc". If executing the SQL in TDengine CLI, the query gets CREATE TABLE tb USING stb TAGS (""abc"").

TDengine Version 2.4.0.7 and JDBC version taos-jdbcdriver-2.0.37 with JNI connection



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source