diff --git a/docs/en/07-develop/01-connect.md b/docs/en/07-develop/01-connect.md
index af5f171f8c..9b1fbad6dd 100644
--- a/docs/en/07-develop/01-connect.md
+++ b/docs/en/07-develop/01-connect.md
@@ -109,7 +109,7 @@ If you are using Maven to manage your project, simply add the following dependen
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
```
diff --git a/docs/en/07-develop/05-stmt.md b/docs/en/07-develop/05-stmt.md
index 4503bb8bd3..4e49145628 100644
--- a/docs/en/07-develop/05-stmt.md
+++ b/docs/en/07-develop/05-stmt.md
@@ -28,8 +28,15 @@ Next, we continue to use smart meters as an example to demonstrate the efficient
+
+There are two kinds of interfaces for parameter binding: one is the standard JDBC interface, and the other is an extended interface. The extended interface offers better performance.
+
```java
-{{#include docs/examples/java/src/main/java/com/taos/example/WSParameterBindingBasicDemo.java:para_bind}}
+{{#include docs/examples/java/src/main/java/com/taos/example/WSParameterBindingStdInterfaceDemo.java:para_bind}}
+```
+
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/WSParameterBindingExtendInterfaceDemo.java:para_bind}}
```
This is a [more detailed parameter binding example](https://github.com/taosdata/TDengine/blob/main/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingFullDemo.java)
diff --git a/docs/en/14-reference/05-connector/14-java.md b/docs/en/14-reference/05-connector/14-java.md
index 10e4ec6d42..f52b7e71f7 100644
--- a/docs/en/14-reference/05-connector/14-java.md
+++ b/docs/en/14-reference/05-connector/14-java.md
@@ -30,33 +30,34 @@ The JDBC driver implementation for TDengine strives to be consistent with relati
## Version History
-| taos-jdbcdriver Version | Major Changes | TDengine Version |
-| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
-| 3.4.0 | 1. Replaced fastjson library with jackson.
2. WebSocket uses a separate protocol identifier.
3. Optimized background thread usage to avoid user misuse leading to timeouts. | - |
-| 3.3.4 | Fixed getInt error when data type is float. | - |
-| 3.3.3 | Fixed memory leak caused by closing WebSocket statement. | - |
-| 3.3.2 | 1. Optimized parameter binding performance under WebSocket connection.
2. Improved support for mybatis. | - |
-| 3.3.0 | 1. Optimized data transmission performance under WebSocket connection.
2. Supports skipping SSL verification, off by default. | 3.3.2.0 and higher |
-| 3.2.11 | Fixed a bug in closing result set in Native connection. | - |
-| 3.2.10 | 1. REST/WebSocket connections support data compression during transmission.
2. WebSocket automatic reconnection mechanism, off by default.
3. Connection class provides methods for schemaless writing.
4. Optimized data fetching performance for native connections.
5. Fixed some known issues.
6. Metadata retrieval functions can return a list of supported functions. | - |
-| 3.2.9 | Fixed bug in closing WebSocket prepareStatement. | - |
-| 3.2.8 | 1. Optimized auto-commit.
2. Fixed manual commit bug in WebSocket.
3. Optimized WebSocket prepareStatement using a single connection.
4. Metadata supports views. | - |
-| 3.2.7 | 1. Supports VARBINARY and GEOMETRY types.
2. Added timezone setting support for native connections.
3. Added WebSocket automatic reconnection feature. | 3.2.0.0 and higher |
-| 3.2.5 | Data subscription adds committed() and assignment() methods. | 3.1.0.3 and higher |
-| 3.2.4 | Data subscription adds enable.auto.commit parameter under WebSocket connection, as well as unsubscribe() method. | - |
-| 3.2.3 | Fixed ResultSet data parsing failure in some cases. | - |
-| 3.2.2 | New feature: Data subscription supports seek function. | 3.0.5.0 and higher |
-| 3.2.1 | 1. WebSocket connection supports schemaless and prepareStatement writing.
2. Consumer poll returns result set as ConsumerRecord, which can be accessed through value() method. | 3.0.3.0 and higher |
-| 3.2.0 | Connection issues, not recommended for use. | - |
-| 3.1.0 | WebSocket connection supports subscription function. | - |
-| 3.0.1 - 3.0.4 | Fixed data parsing errors in result sets under some conditions. 3.0.1 compiled in JDK 11 environment, other versions recommended for JDK 8. | - |
-| 3.0.0 | Supports TDengine 3.0 | 3.0.0.0 and higher |
-| 2.0.42 | Fixed wasNull interface return value in WebSocket connection. | - |
-| 2.0.41 | Fixed username and password encoding method in REST connection. | - |
-| 2.0.39 - 2.0.40 | Added REST connection/request timeout settings. | - |
-| 2.0.38 | JDBC REST connection adds batch fetching function. | - |
-| 2.0.37 | Added support for json tag. | - |
-| 2.0.36 | Added support for schemaless writing. | - |
+| taos-jdbcdriver Version | Major Changes | TDengine Version |
+| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
+| 3.5.0 | 1. Optimized the performance of WebSocket connection parameter binding, supporting parameter binding queries using binary data.
2. Optimized the performance of small queries in WebSocket connection.
3. Added support for setting time zone on WebSocket connection. | 3.3.5.0 and higher |
+| 3.4.0 | 1. Replaced fastjson library with jackson.
2. WebSocket uses a separate protocol identifier.
3. Optimized background thread usage to avoid user misuse leading to timeouts. | - |
+| 3.3.4 | Fixed getInt error when data type is float. | - |
+| 3.3.3 | Fixed memory leak caused by closing WebSocket statement. | - |
+| 3.3.2 | 1. Optimized parameter binding performance under WebSocket connection.
2. Improved support for mybatis. | - |
+| 3.3.0 | 1. Optimized data transmission performance under WebSocket connection.
2. Supports skipping SSL verification, off by default. | 3.3.2.0 and higher |
+| 3.2.11 | Fixed a bug in closing result set in Native connection. | - |
+| 3.2.10 | 1. REST/WebSocket connections support data compression during transmission.
2. WebSocket automatic reconnection mechanism, off by default.
3. Connection class provides methods for schemaless writing.
4. Optimized data fetching performance for native connections.
5. Fixed some known issues.
6. Metadata retrieval functions can return a list of supported functions. | - |
+| 3.2.9 | Fixed bug in closing WebSocket prepareStatement. | - |
+| 3.2.8 | 1. Optimized auto-commit.
2. Fixed manual commit bug in WebSocket.
3. Optimized WebSocket prepareStatement using a single connection.
4. Metadata supports views. | - |
+| 3.2.7 | 1. Supports VARBINARY and GEOMETRY types.
2. Added timezone setting support for native connections.
3. Added WebSocket automatic reconnection feature. | 3.2.0.0 and higher |
+| 3.2.5 | Data subscription adds committed() and assignment() methods. | 3.1.0.3 and higher |
+| 3.2.4 | Data subscription adds enable.auto.commit parameter under WebSocket connection, as well as unsubscribe() method. | - |
+| 3.2.3 | Fixed ResultSet data parsing failure in some cases. | - |
+| 3.2.2 | New feature: Data subscription supports seek function. | 3.0.5.0 and higher |
+| 3.2.1 | 1. WebSocket connection supports schemaless and prepareStatement writing.
2. Consumer poll returns result set as ConsumerRecord, which can be accessed through value() method. | 3.0.3.0 and higher |
+| 3.2.0 | Connection issues, not recommended for use. | - |
+| 3.1.0 | WebSocket connection supports subscription function. | - |
+| 3.0.1 - 3.0.4 | Fixed data parsing errors in result sets under some conditions. 3.0.1 compiled in JDK 11 environment, other versions recommended for JDK 8. | - |
+| 3.0.0 | Supports TDengine 3.0 | 3.0.0.0 and higher |
+| 2.0.42 | Fixed wasNull interface return value in WebSocket connection. | - |
+| 2.0.41 | Fixed username and password encoding method in REST connection. | - |
+| 2.0.39 - 2.0.40 | Added REST connection/request timeout settings. | - |
+| 2.0.38 | JDBC REST connection adds batch fetching function. | - |
+| 2.0.37 | Added support for json tag. | - |
+| 2.0.36 | Added support for schemaless writing. | - |
## Exceptions and Error Codes
@@ -75,47 +76,47 @@ The error codes that the JDBC connector may report include 4 types:
Please refer to the specific error codes:
-| Error Code | Description | Suggested Actions |
-| ---------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
-| 0x2301 | connection already closed | The connection is already closed, check the connection status, or recreate the connection to execute related commands. |
-| 0x2302 | this operation is NOT supported currently! | The current interface is not supported, consider switching to another connection method. |
-| 0x2303 | invalid variables | Invalid parameters, please check the interface specifications and adjust the parameter types and sizes. |
-| 0x2304 | statement is closed | The statement is already closed, check if the statement was used after being closed, or if the connection is normal. |
-| 0x2305 | resultSet is closed | The resultSet has been released, check if the resultSet was used after being released. |
-| 0x2306 | Batch is empty! | Add parameters to prepareStatement before executing executeBatch. |
-| 0x2307 | Can not issue data manipulation statements with executeQuery() | Use executeUpdate() for update operations, not executeQuery(). |
-| 0x2308 | Can not issue SELECT via executeUpdate() | Use executeQuery() for query operations, not executeUpdate(). |
-| 0x230d | parameter index out of range | Parameter out of bounds, check the reasonable range of parameters. |
-| 0x230e | connection already closed | The connection is already closed, check if the Connection was used after being closed, or if the connection is normal. |
-| 0x230f | unknown sql type in tdengine | Check the Data Type types supported by TDengine. |
-| 0x2310 | can't register JDBC-JNI driver | Cannot register JNI driver, check if the url is correctly filled. |
-| 0x2312 | url is not set | Check if the REST connection url is correctly filled. |
-| 0x2314 | numeric value out of range | Check if the correct interface was used for numeric types in the result set. |
-| 0x2315 | unknown taos type in tdengine | When converting TDengine data types to JDBC data types, check if the correct TDengine data type was specified. |
-| 0x2317 | | Incorrect request type used in REST connection. |
-| 0x2318 | | Data transmission error occurred in REST connection, check the network situation and retry. |
-| 0x2319 | user is required | Username information is missing when creating a connection. |
-| 0x231a | password is required | Password information is missing when creating a connection. |
-| 0x231c | httpEntity is null, sql: | An exception occurred in REST connection execution. |
-| 0x231d | can't create connection with server within | Increase the httpConnectTimeout parameter to extend the connection time, or check the connection with taosAdapter. |
-| 0x231e | failed to complete the task within the specified time | Increase the messageWaitTimeout parameter to extend the execution time, or check the connection with taosAdapter. |
-| 0x2350 | unknown error | Unknown exception, please provide feedback to the developers on github. |
-| 0x2352 | Unsupported encoding | An unsupported character encoding set was specified in the local connection. |
-| 0x2353 | internal error of database, please see taoslog for more details | An error occurred while executing prepareStatement in local connection, check taos log for troubleshooting. |
-| 0x2354 | JNI connection is NULL | The Connection was already closed when executing commands in local connection. Check the connection with TDengine. |
-| 0x2355 | JNI result set is NULL | The result set is abnormal in local connection, check the connection and retry. |
-| 0x2356 | invalid num of fields | The meta information of the result set obtained in local connection does not match. |
-| 0x2357 | empty sql string | Fill in the correct SQL for execution. |
-| 0x2359 | JNI alloc memory failed, please see taoslog for more details | Memory allocation error in local connection, check taos log for troubleshooting. |
-| 0x2371 | consumer properties must not be null! | Parameters are null when creating a subscription, fill in the correct parameters. |
-| 0x2372 | configs contain empty key, failed to set consumer property | The parameter key contains empty values, fill in the correct parameters. |
-| 0x2373 | failed to set consumer property, | The parameter value contains empty values, fill in the correct parameters. |
-| 0x2375 | topic reference has been destroyed | During the data subscription process, the topic reference was released. Check the connection with TDengine. |
+| Error Code | Description | Suggested Actions |
+| ---------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
+| 0x2301 | connection already closed | The connection is already closed, check the connection status, or recreate the connection to execute related commands. |
+| 0x2302 | this operation is NOT supported currently! | The current interface is not supported, consider switching to another connection method. |
+| 0x2303 | invalid variables | Invalid parameters, please check the interface specifications and adjust the parameter types and sizes. |
+| 0x2304 | statement is closed | The statement is already closed, check if the statement was used after being closed, or if the connection is normal. |
+| 0x2305 | resultSet is closed | The resultSet has been released, check if the resultSet was used after being released. |
+| 0x2306 | Batch is empty! | Add parameters to prepareStatement before executing executeBatch. |
+| 0x2307 | Can not issue data manipulation statements with executeQuery() | Use executeUpdate() for update operations, not executeQuery(). |
+| 0x2308 | Can not issue SELECT via executeUpdate() | Use executeQuery() for query operations, not executeUpdate(). |
+| 0x230d | parameter index out of range | Parameter out of bounds, check the reasonable range of parameters. |
+| 0x230e | connection already closed | The connection is already closed, check if the Connection was used after being closed, or if the connection is normal. |
+| 0x230f | unknown sql type in tdengine | Check the Data Type types supported by TDengine. |
+| 0x2310 | can't register JDBC-JNI driver | Cannot register JNI driver, check if the url is correctly filled. |
+| 0x2312 | url is not set | Check if the REST connection url is correctly filled. |
+| 0x2314 | numeric value out of range | Check if the correct interface was used for numeric types in the result set. |
+| 0x2315 | unknown taos type in tdengine | When converting TDengine data types to JDBC data types, check if the correct TDengine data type was specified. |
+| 0x2317 | | Incorrect request type used in REST connection. |
+| 0x2318 | | Data transmission error occurred in REST connection, check the network situation and retry. |
+| 0x2319 | user is required | Username information is missing when creating a connection. |
+| 0x231a | password is required | Password information is missing when creating a connection. |
+| 0x231c | httpEntity is null, sql: | An exception occurred in REST connection execution. |
+| 0x231d | can't create connection with server within | Increase the httpConnectTimeout parameter to extend the connection time, or check the connection with taosAdapter. |
+| 0x231e | failed to complete the task within the specified time | Increase the messageWaitTimeout parameter to extend the execution time, or check the connection with taosAdapter. |
+| 0x2350 | unknown error | Unknown exception, please provide feedback to the developers on github. |
+| 0x2352 | Unsupported encoding | An unsupported character encoding set was specified in the local connection. |
+| 0x2353 | internal error of database, please see taoslog for more details | An error occurred while executing prepareStatement in local connection, check taos log for troubleshooting. |
+| 0x2354 | JNI connection is NULL | The Connection was already closed when executing commands in local connection. Check the connection with TDengine. |
+| 0x2355 | JNI result set is NULL | The result set is abnormal in local connection, check the connection and retry. |
+| 0x2356 | invalid num of fields | The meta information of the result set obtained in local connection does not match. |
+| 0x2357 | empty sql string | Fill in the correct SQL for execution. |
+| 0x2359 | JNI alloc memory failed, please see taoslog for more details | Memory allocation error in local connection, check taos log for troubleshooting. |
+| 0x2371 | consumer properties must not be null! | Parameters are null when creating a subscription, fill in the correct parameters. |
+| 0x2372 | configs contain empty key, failed to set consumer property | The parameter key contains empty values, fill in the correct parameters. |
+| 0x2373 | failed to set consumer property, | The parameter value contains empty values, fill in the correct parameters. |
+| 0x2375 | topic reference has been destroyed | During the data subscription process, the topic reference was released. Check the connection with TDengine. |
| 0x2376 | failed to set consumer topic, topic name is empty | During the data subscription process, the subscription topic name is empty. Check if the specified topic name is correctly filled. |
-| 0x2377 | consumer reference has been destroyed | The data transmission channel for the subscription has been closed, check the connection with TDengine. |
-| 0x2378 | consumer create error | Data subscription creation failed, check the error information and taos log for troubleshooting. |
-| 0x2379 | seek offset must not be a negative number | The seek interface parameter must not be negative, use the correct parameters. |
-| 0x237a | vGroup not found in result set | VGroup not assigned to the current consumer, due to the Rebalance mechanism causing the Consumer and VGroup to be unbound. |
+| 0x2377 | consumer reference has been destroyed | The data transmission channel for the subscription has been closed, check the connection with TDengine. |
+| 0x2378 | consumer create error | Data subscription creation failed, check the error information and taos log for troubleshooting. |
+| 0x2379 | seek offset must not be a negative number | The seek interface parameter must not be negative, use the correct parameters. |
+| 0x237a | vGroup not found in result set | VGroup not assigned to the current consumer, due to the Rebalance mechanism causing the Consumer and VGroup to be unbound. |
- [TDengine Java Connector Error Code](https://github.com/taosdata/taos-connector-jdbc/blob/main/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java)
@@ -489,16 +490,16 @@ For example: if the password is specified as taosdata in the URL and as taosdemo
List of interface methods that return `true` for supported features, others not explicitly mentioned return `false`.
-| Interface Method | Description |
-|--------------------------------------------------------|-----------------------------------------------------|
-| `boolean nullsAreSortedAtStart()` | Determines if `NULL` values are sorted at the start |
-| `boolean storesLowerCaseIdentifiers()` | Determines if the database stores identifiers in lowercase |
-| `boolean supportsAlterTableWithAddColumn()` | Determines if the database supports adding columns with `ALTER TABLE` |
-| `boolean supportsAlterTableWithDropColumn()` | Determines if the database supports dropping columns with `ALTER TABLE` |
-| `boolean supportsColumnAliasing()` | Determines if the database supports column aliasing |
-| `boolean supportsGroupBy()` | Determines if the database supports `GROUP BY` statements |
-| `boolean isCatalogAtStart()` | Determines if the catalog name appears at the start of the fully qualified name in the database |
-| `boolean supportsCatalogsInDataManipulation()` | Determines if the database supports catalog names in data manipulation statements |
+| Interface Method | Description |
+| ---------------------------------------------- | ----------------------------------------------------------------------------------------------- |
+| `boolean nullsAreSortedAtStart()` | Determines if `NULL` values are sorted at the start |
+| `boolean storesLowerCaseIdentifiers()` | Determines if the database stores identifiers in lowercase |
+| `boolean supportsAlterTableWithAddColumn()` | Determines if the database supports adding columns with `ALTER TABLE` |
+| `boolean supportsAlterTableWithDropColumn()` | Determines if the database supports dropping columns with `ALTER TABLE` |
+| `boolean supportsColumnAliasing()` | Determines if the database supports column aliasing |
+| `boolean supportsGroupBy()` | Determines if the database supports `GROUP BY` statements |
+| `boolean isCatalogAtStart()` | Determines if the catalog name appears at the start of the fully qualified name in the database |
+| `boolean supportsCatalogsInDataManipulation()` | Determines if the database supports catalog names in data manipulation statements |
### Connection Features
diff --git a/docs/examples/JDBC/JDBCDemo/pom.xml b/docs/examples/JDBC/JDBCDemo/pom.xml
index 4b3e1ab675..e0c17ffbac 100644
--- a/docs/examples/JDBC/JDBCDemo/pom.xml
+++ b/docs/examples/JDBC/JDBCDemo/pom.xml
@@ -19,7 +19,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
org.locationtech.jts
diff --git a/docs/examples/JDBC/SpringJdbcTemplate/pom.xml b/docs/examples/JDBC/SpringJdbcTemplate/pom.xml
index 34719dc135..b48f17acce 100644
--- a/docs/examples/JDBC/SpringJdbcTemplate/pom.xml
+++ b/docs/examples/JDBC/SpringJdbcTemplate/pom.xml
@@ -47,7 +47,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
diff --git a/docs/examples/JDBC/connectionPools/pom.xml b/docs/examples/JDBC/connectionPools/pom.xml
index e3ef30d2f8..8fca6ce1b2 100644
--- a/docs/examples/JDBC/connectionPools/pom.xml
+++ b/docs/examples/JDBC/connectionPools/pom.xml
@@ -18,7 +18,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
diff --git a/docs/examples/JDBC/consumer-demo/pom.xml b/docs/examples/JDBC/consumer-demo/pom.xml
index 709f87d9c1..997643c3de 100644
--- a/docs/examples/JDBC/consumer-demo/pom.xml
+++ b/docs/examples/JDBC/consumer-demo/pom.xml
@@ -17,7 +17,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
com.google.guava
diff --git a/docs/examples/JDBC/mybatisplus-demo/pom.xml b/docs/examples/JDBC/mybatisplus-demo/pom.xml
index 2077e31d8d..27e62695bc 100644
--- a/docs/examples/JDBC/mybatisplus-demo/pom.xml
+++ b/docs/examples/JDBC/mybatisplus-demo/pom.xml
@@ -47,7 +47,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
diff --git a/docs/examples/JDBC/springbootdemo/pom.xml b/docs/examples/JDBC/springbootdemo/pom.xml
index df8a3f5d61..f42799119b 100644
--- a/docs/examples/JDBC/springbootdemo/pom.xml
+++ b/docs/examples/JDBC/springbootdemo/pom.xml
@@ -70,7 +70,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
diff --git a/docs/examples/JDBC/taosdemo/pom.xml b/docs/examples/JDBC/taosdemo/pom.xml
index c36973947b..936a133e31 100644
--- a/docs/examples/JDBC/taosdemo/pom.xml
+++ b/docs/examples/JDBC/taosdemo/pom.xml
@@ -67,7 +67,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
diff --git a/docs/examples/java/pom.xml b/docs/examples/java/pom.xml
index e1a9504249..9b3a8c147d 100644
--- a/docs/examples/java/pom.xml
+++ b/docs/examples/java/pom.xml
@@ -22,7 +22,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
diff --git a/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingExtendInterfaceDemo.java b/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingExtendInterfaceDemo.java
new file mode 100644
index 0000000000..8a83c27bbc
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingExtendInterfaceDemo.java
@@ -0,0 +1,87 @@
+package com.taos.example;
+
+import com.taosdata.jdbc.ws.TSWSPreparedStatement;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.Random;
+
+// ANCHOR: para_bind
+public class WSParameterBindingExtendInterfaceDemo {
+
+ // modify host to your own
+ private static final String host = "127.0.0.1";
+ private static final Random random = new Random(System.currentTimeMillis());
+ private static final int numOfSubTable = 10, numOfRow = 10;
+
+ public static void main(String[] args) throws SQLException {
+
+ String jdbcUrl = "jdbc:TAOS-WS://" + host + ":6041";
+ try (Connection conn = DriverManager.getConnection(jdbcUrl, "root", "taosdata")) {
+ init(conn);
+
+ String sql = "INSERT INTO ? USING power.meters TAGS(?,?) VALUES (?,?,?,?)";
+
+ try (TSWSPreparedStatement pstmt = conn.prepareStatement(sql).unwrap(TSWSPreparedStatement.class)) {
+
+ for (int i = 1; i <= numOfSubTable; i++) {
+ // set table name
+ pstmt.setTableName("d_bind_" + i);
+
+ // set tags
+ pstmt.setTagInt(0, i);
+ pstmt.setTagString(1, "location_" + i);
+
+ // set column ts
+ ArrayList tsList = new ArrayList<>();
+ long current = System.currentTimeMillis();
+ for (int j = 0; j < numOfRow; j++)
+ tsList.add(current + j);
+ pstmt.setTimestamp(0, tsList);
+
+ // set column current
+ ArrayList currentList = new ArrayList<>();
+ for (int j = 0; j < numOfRow; j++)
+ currentList.add(random.nextFloat() * 30);
+ pstmt.setFloat(1, currentList);
+
+ // set column voltage
+ ArrayList voltageList = new ArrayList<>();
+ for (int j = 0; j < numOfRow; j++)
+ voltageList.add(random.nextInt(300));
+ pstmt.setInt(2, voltageList);
+
+ // set column phase
+ ArrayList phaseList = new ArrayList<>();
+ for (int j = 0; j < numOfRow; j++)
+ phaseList.add(random.nextFloat());
+ pstmt.setFloat(3, phaseList);
+ // add column
+ pstmt.columnDataAddBatch();
+ }
+ // execute column
+ pstmt.columnDataExecuteBatch();
+ // you can check exeResult here
+ System.out.println("Successfully inserted " + (numOfSubTable * numOfRow) + " rows to power.meters.");
+ }
+ } catch (Exception ex) {
+ // please refer to the JDBC specifications for detailed exceptions info
+ System.out.printf("Failed to insert to table meters using stmt, %sErrMessage: %s%n",
+ ex instanceof SQLException ? "ErrCode: " + ((SQLException) ex).getErrorCode() + ", " : "",
+ ex.getMessage());
+ // Print stack trace for context in examples. Use logging in production.
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+ private static void init(Connection conn) throws SQLException {
+ try (Statement stmt = conn.createStatement()) {
+ stmt.execute("CREATE DATABASE IF NOT EXISTS power");
+ stmt.execute("USE power");
+ stmt.execute(
+ "CREATE STABLE IF NOT EXISTS power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))");
+ }
+ }
+}
+// ANCHOR_END: para_bind
diff --git a/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingBasicDemo.java b/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingStdInterfaceDemo.java
similarity index 61%
rename from docs/examples/java/src/main/java/com/taos/example/WSParameterBindingBasicDemo.java
rename to docs/examples/java/src/main/java/com/taos/example/WSParameterBindingStdInterfaceDemo.java
index 1353ebbddc..7f0e523b97 100644
--- a/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingBasicDemo.java
+++ b/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingStdInterfaceDemo.java
@@ -1,12 +1,10 @@
package com.taos.example;
-import com.taosdata.jdbc.ws.TSWSPreparedStatement;
-
import java.sql.*;
import java.util.Random;
// ANCHOR: para_bind
-public class WSParameterBindingBasicDemo {
+public class WSParameterBindingStdInterfaceDemo {
// modify host to your own
private static final String host = "127.0.0.1";
@@ -19,31 +17,29 @@ public class WSParameterBindingBasicDemo {
try (Connection conn = DriverManager.getConnection(jdbcUrl, "root", "taosdata")) {
init(conn);
- String sql = "INSERT INTO ? USING power.meters TAGS(?,?) VALUES (?,?,?,?)";
+ // If you are certain that the child table exists, you can avoid binding the tag column to improve performance.
+ String sql = "INSERT INTO power.meters (tbname, groupid, location, ts, current, voltage, phase) VALUES (?,?,?,?,?,?,?)";
- try (TSWSPreparedStatement pstmt = conn.prepareStatement(sql).unwrap(TSWSPreparedStatement.class)) {
+ try (PreparedStatement pstmt = conn.prepareStatement(sql)) {
+ long current = System.currentTimeMillis();
for (int i = 1; i <= numOfSubTable; i++) {
- // set table name
- pstmt.setTableName("d_bind_" + i);
-
- // set tags
- pstmt.setTagInt(0, i);
- pstmt.setTagString(1, "location_" + i);
-
- // set columns
- long current = System.currentTimeMillis();
for (int j = 0; j < numOfRow; j++) {
- pstmt.setTimestamp(1, new Timestamp(current + j));
- pstmt.setFloat(2, random.nextFloat() * 30);
- pstmt.setInt(3, random.nextInt(300));
- pstmt.setFloat(4, random.nextFloat());
+ pstmt.setString(1, "d_bind_" + i);
+
+ pstmt.setInt(2, i);
+ pstmt.setString(3, "location_" + i);
+
+ pstmt.setTimestamp(4, new Timestamp(current + j));
+ pstmt.setFloat(5, random.nextFloat() * 30);
+ pstmt.setInt(6, random.nextInt(300));
+ pstmt.setFloat(7, random.nextFloat());
pstmt.addBatch();
}
- int[] exeResult = pstmt.executeBatch();
- // you can check exeResult here
- System.out.println("Successfully inserted " + exeResult.length + " rows to power.meters.");
}
+ int[] exeResult = pstmt.executeBatch();
+ // you can check exeResult here
+ System.out.println("Successfully inserted " + exeResult.length + " rows to power.meters.");
}
} catch (Exception ex) {
// please refer to the JDBC specifications for detailed exceptions info
diff --git a/docs/examples/java/src/test/java/com/taos/test/TestAll.java b/docs/examples/java/src/test/java/com/taos/test/TestAll.java
index a92ddd116c..f73b9d42ee 100644
--- a/docs/examples/java/src/test/java/com/taos/test/TestAll.java
+++ b/docs/examples/java/src/test/java/com/taos/test/TestAll.java
@@ -118,9 +118,14 @@ public class TestAll {
}
@Test
- public void testWsStmtBasic() throws Exception {
+ public void testWsStmtStd() throws Exception {
dropDB("power");
- WSParameterBindingBasicDemo.main(args);
+ WSParameterBindingStdInterfaceDemo.main(args);
+ }
+ @Test
+ public void testWsStmtExtend() throws Exception {
+ dropDB("power");
+ WSParameterBindingExtendInterfaceDemo.main(args);
}
@Test
diff --git a/docs/zh/07-develop/01-connect/index.md b/docs/zh/07-develop/01-connect/index.md
index 2381c49d93..e81a9e08c7 100644
--- a/docs/zh/07-develop/01-connect/index.md
+++ b/docs/zh/07-develop/01-connect/index.md
@@ -89,7 +89,7 @@ TDengine 提供了丰富的应用程序开发接口,为了便于用户快速
com.taosdata.jdbc
taos-jdbcdriver
- 3.4.0
+ 3.5.0
```
diff --git a/docs/zh/07-develop/05-stmt.md b/docs/zh/07-develop/05-stmt.md
index 74b44ba8e6..f6c67f98fe 100644
--- a/docs/zh/07-develop/05-stmt.md
+++ b/docs/zh/07-develop/05-stmt.md
@@ -26,10 +26,16 @@ import TabItem from "@theme/TabItem";
## WebSocket 连接
+
+参数绑定有两种接口使用方式,一种是 JDBC 标准接口,一种是扩展接口,扩展接口性能更好一些。
+
```java
-{{#include docs/examples/java/src/main/java/com/taos/example/WSParameterBindingBasicDemo.java:para_bind}}
+{{#include docs/examples/java/src/main/java/com/taos/example/WSParameterBindingStdInterfaceDemo.java:para_bind}}
```
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/WSParameterBindingExtendInterfaceDemo.java:para_bind}}
+```
这是一个[更详细的参数绑定示例](https://github.com/taosdata/TDengine/blob/main/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingFullDemo.java)
diff --git a/docs/zh/14-reference/05-connector/14-java.mdx b/docs/zh/14-reference/05-connector/14-java.mdx
index 27f43676f3..ab7494707b 100644
--- a/docs/zh/14-reference/05-connector/14-java.mdx
+++ b/docs/zh/14-reference/05-connector/14-java.mdx
@@ -33,6 +33,7 @@ TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致
| taos-jdbcdriver 版本 | 主要变化 | TDengine 版本 |
| ------------------| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
+| 3.5.0 | 1. 优化了 WebSocket 连接参数绑定性能,支持参数绑定查询使用二进制数据
2. 优化了 WebSocket 连接在小查询上的性能
3. WebSocket 连接上支持设置时区 | 3.3.5.0 及更高版本 |
| 3.4.0 | 1. 使用 jackson 库替换 fastjson 库
2. WebSocket 采用独立协议标识
3. 优化后台拉取线程使用,避免用户误用导致超时 | - |
| 3.3.4 | 解决了 getInt 在数据类型为 float 报错 | - |
| 3.3.3 | 解决了 WebSocket statement 关闭导致的内存泄漏 | - |