diff --git a/CMakeLists.txt b/CMakeLists.txt
index 71cb0bfd437c9888d6518bc83cfde607b707db4c..9c446b19a548e2f2f84d147d59327bee66d56caa 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -141,12 +141,12 @@ IF (NOT DEFINED TD_CLUSTER)
SET(RELEASE_FLAGS "-O0")
IF (NOT TD_ARM)
IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
- SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
+ SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ELSE ()
- SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
+ SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ENDIF ()
ELSE ()
- SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -Wno-char-subscripts -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
+ SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ENDIF ()
ADD_DEFINITIONS(-DLINUX)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
@@ -156,7 +156,7 @@ IF (NOT DEFINED TD_CLUSTER)
ENDIF ()
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
- SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -Wno-char-subscripts -fsigned-char -munaligned-access -fpack-struct=8 -latomic -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
+ SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -latomic -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ADD_DEFINITIONS(-DLINUX)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
ADD_DEFINITIONS(-DUSE_LIBICONV)
@@ -171,7 +171,7 @@ IF (NOT DEFINED TD_CLUSTER)
ADD_DEFINITIONS(-DPTW32_BUILD)
ADD_DEFINITIONS(-D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
ELSEIF (TD_DARWIN_64)
- SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-unused-variable -Wno-bitfield-constant-conversion")
+ SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
ADD_DEFINITIONS(-DDARWIN)
diff --git a/documentation/webdocs/markdowndocs/Connector.md b/documentation/webdocs/markdowndocs/Connector.md
index 014e88de42df7309d8d6b3aa9b9d0448374edd52..c4a08ca88ee987947a86426fa0aa5cd302fd938a 100644
--- a/documentation/webdocs/markdowndocs/Connector.md
+++ b/documentation/webdocs/markdowndocs/Connector.md
@@ -198,56 +198,104 @@ For the time being, TDengine supports subscription on one table. It is implement
## Java Connector
-### JDBC Interface
+To Java delevopers, TDengine provides `taos-jdbcdriver` according to the JDBC(3.0) API. Users can find and download it through [Sonatype Repository][1].
-TDengine provides a JDBC driver `taos-jdbcdriver-x.x.x.jar` for Enterprise Java developers. TDengine's JDBC Driver is implemented as a subset of the standard JDBC 3.0 Specification and supports the most common Java development frameworks. The driver have been published to dependency repositories such as Sonatype Maven Repository, and users could refer to the following `pom.xml` configuration file.
+Since the native language of TDengine is C, the necessary TDengine library should be checked before using the taos-jdbcdriver:
+
+* libtaos.so (Linux)
+ After TDengine is installed successfully, the library `libtaos.so` will be automatically copied to the `/usr/lib/`, which is the system's default search path.
+
+* taos.dll (Windows)
+ After TDengine client is installed, the library `taos.dll` will be automatically copied to the `C:/Windows/System32`, which is the system's default search path.
+
+> Note: Please make sure that TDengine Windows client has been installed if developing on Windows.
+
+Since TDengine is time-series database, there are still some differences compared with traditional databases in using TDengine JDBC driver:
+* TDengine doesn't allow to delete/modify a single record, and thus JDBC driver also has no such method.
+* No support for transaction
+* No support for union between tables
+* No support for nested query,`There is at most one open ResultSet for each Connection. Thus, TSDB JDBC Driver will close current ResultSet if it is not closed and a new query begins`.
+
+## Version list of TAOS-JDBCDriver and required TDengine and JDK
+
+| taos-jdbcdriver | TDengine | JDK |
+| --- | --- | --- |
+| 1.0.3 | 1.6.1.x or higher | 1.8.x |
+| 1.0.2 | 1.6.1.x or higher | 1.8.x |
+| 1.0.1 | 1.6.1.x or higher | 1.8.x |
+
+## DataType in TDengine and Java
+
+The datatypes in TDengine include timestamp, number, string and boolean, which are converted as follows in Java:
+
+| TDengine | Java |
+| --- | --- |
+| TIMESTAMP | java.sql.Timestamp |
+| INT | java.lang.Integer |
+| BIGINT | java.lang.Long |
+| FLOAT | java.lang.Float |
+| DOUBLE | java.lang.Double |
+| SMALLINT, TINYINT |java.lang.Short |
+| BOOL | java.lang.Boolean |
+| BINARY, NCHAR | java.lang.String |
+
+## How to get TAOS-JDBC Driver
+
+### maven repository
+
+taos-jdbcdriver has been published to [Sonatype Repository][1]:
+* [sonatype][8]
+* [mvnrepository][9]
+* [maven.aliyun][10]
+
+Using the following pom.xml for maven projects
```xml
-
-
- oss-sonatype
- oss-sonatype
- https://oss.sonatype.org/content/groups/public
-
-
-
com.taosdata.jdbc
taos-jdbcdriver
- 1.0.1
+ 1.0.3
```
-Please note the JDBC driver itself relies on a native library written in C. On a Linux OS, the driver relies on a `libtaos.so` native library, where .so stands for "Shared Object". After the successful installation of TDengine on Linux, `libtaos.so` should be automatically copied to `/usr/local/lib/taos` and added to the system's default search path. On a Windows OS, the driver relies on a `taos.dll` native library, where .dll stands for "Dynamic Link Library". After the successful installation of the TDengine client on Windows, the `taos-jdbcdriver.jar` file can be found in `C:/TDengine/driver/JDBC`; the `taos.dll` file can be found in `C:/TDengine/driver/C` and should have been automatically copied to the system's searching path `C:/Windows/System32`.
+### JAR file from the source code
-Developers can refer to the Oracle's official JDBC API documentation for detailed usage on classes and methods. However, there are some differences of connection configurations and supported methods in the driver implementation between TDengine and traditional relational databases.
+After downloading the [TDengine][3] source code, execute `mvn clean package` in the directory `src/connector/jdbc` and then the corresponding jar file is generated.
-For database connections, TDengine's JDBC driver has the following configurable parameters in the JDBC URL. The standard format of a TDengine JDBC URL is:
+## Usage
-`jdbc:TSDB://{host_ip}:{port}/{database_name}?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
+### get the connection
-where `{}` marks the required parameters and `[]` marks the optional. The usage of each parameter is pretty straightforward:
+```java
+Class.forName("com.taosdata.jdbc.TSDBDriver");
+String jdbcUrl = "jdbc:TAOS://127.0.0.1:6030/log?user=root&password=taosdata";
+Connection conn = DriverManager.getConnection(jdbcUrl);
+```
+> `6030` is the default port and `log` is the default database for system monitor.
-* user - login user name for TDengine; by default, it's `root`
-* password - login password; by default, it's `taosdata`
-* charset - the client-side charset; by default, it's the operation system's charset
-* cfgdir - the directory of TDengine client configuration file; by default it's `/etc/taos` on Linux and `C:\TDengine/cfg` on Windows
-* locale - the language environment of TDengine client; by default, it's the operation system's locale
-* timezone - the timezone of the TDengine client; by default, it's the operation system's timezone
+A normal JDBC URL looks as follows:
+`jdbc:TSDB://{host_ip}:{port}/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
-All parameters can be configured at the time when creating a connection using the java.sql.DriverManager class, for example:
+values in `{}` are necessary while values in `[]` are optional。Each option in the above URL denotes:
-```java
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.util.Properties;
-import com.taosdata.jdbc.TSDBDriver;
+* user:user name for login, defaultly root。
+* password:password for login,defaultly taosdata。
+* charset:charset for client,defaultly system charset
+* cfgdir:log directory for client, defaultly _/etc/taos/_ on Linux and _C:/TDengine/cfg_ on Windows。
+* locale:language for client,defaultly system locale。
+* timezone:timezone for client,defaultly system timezone。
+The options above can be configures (`ordered by priority`):
+1. JDBC URL
+
+ As explained above.
+2. java.sql.DriverManager.getConnection(String jdbcUrl, Properties connProps)
+```java
public Connection getConn() throws Exception{
- Class.forName("com.taosdata.jdbc.TSDBDriver");
- String jdbcUrl = "jdbc:TAOS://127.0.0.1:0/db?user=root&password=taosdata";
+ Class.forName("com.taosdata.jdbc.TSDBDriver");
+ String jdbcUrl = "jdbc:TAOS://127.0.0.1:0/log?user=root&password=taosdata";
Properties connProps = new Properties();
connProps.setProperty(TSDBDriver.PROPERTY_KEY_USER, "root");
connProps.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD, "taosdata");
@@ -260,16 +308,204 @@ public Connection getConn() throws Exception{
}
```
-Except `cfgdir`, all the parameters listed above can also be configured in the configuration file. The properties specified when calling DriverManager.getConnection() has the highest priority among all configuration methods. The JDBC URL has the second-highest priority, and the configuration file has the lowest priority. The explicitly configured parameters in a method with higher priorities always overwrite that same parameter configured in methods with lower priorities. For example, if `charset` is explicitly configured as "UTF-8" in the JDBC URL and "GKB" in the `taos.cfg` file, then "UTF-8" will be used.
+3. Configuration file (taos.cfg)
+
+ Default configuration file is _/var/lib/taos/taos.cfg_ On Linux and _C:\TDengine\cfg\taos.cfg_ on Windows
+```properties
+# client default username
+# defaultUser root
-Although the JDBC driver is implemented following the JDBC standard as much as possible, there are major differences between TDengine and traditional databases in terms of data models that lead to the differences in the driver implementation. Here is a list of head-ups for developers who have plenty of experience on traditional databases but little on TDengine:
+# client default password
+# defaultPass taosdata
-* TDengine does NOT support updating or deleting a specific record, which leads to some unsupported methods in the JDBC driver
-* TDengine currently does not support `join` or `union` operations, and thus, is lack of support for associated methods in the JDBC driver
-* TDengine supports batch insertions which are controlled at the level of SQL statement writing instead of API calls
-* TDengine doesn't support nested queries and neither does the JDBC driver. Thus for each established connection to TDengine, there should be only one open result set associated with it
+# default system charset
+# charset UTF-8
+
+# system locale
+# locale en_US.UTF-8
+```
+> More options can refer to [client configuration][13]
+
+### Create databases and tables
+
+```java
+Statement stmt = conn.createStatement();
+
+// create database
+stmt.executeUpdate("create database if not exists db");
+
+// use database
+stmt.executeUpdate("use db");
+
+// create table
+stmt.executeUpdate("create table if not exists tb (ts timestamp, temperature int, humidity float)");
+```
+> Note: if no step like `use db`, the name of database must be added as prefix like _db.tb_ when operating on tables
+
+### Insert data
+
+```java
+// insert data
+int affectedRows = stmt.executeUpdate("insert into tb values(now, 23, 10.3) (now + 1s, 20, 9.3)");
+
+System.out.println("insert " + affectedRows + " rows.");
+```
+> _now_ is the server time.
+> _now+1s_ is 1 second later than current server time. The time unit includes: _a_(millisecond), _s_(second), _m_(minute), _h_(hour), _d_(day), _w_(week), _n_(month), _y_(year).
+
+### Query database
+
+```java
+// query data
+ResultSet resultSet = stmt.executeQuery("select * from tb");
+
+Timestamp ts = null;
+int temperature = 0;
+float humidity = 0;
+while(resultSet.next()){
+
+ ts = resultSet.getTimestamp(1);
+ temperature = resultSet.getInt(2);
+ humidity = resultSet.getFloat("humidity");
+
+ System.out.printf("%s, %d, %s\n", ts, temperature, humidity);
+}
+```
+> query is consistent with relational database. The subscript start with 1 when retrieving return results. It is recommended to use the column name to retrieve results.
+
+### Close all
+
+```java
+resultSet.close();
+stmt.close();
+conn.close();
+```
+> `please make sure the connection is closed to avoid the error like connection leakage`
+
+## Using connection pool
+
+**HikariCP**
+
+* dependence in pom.xml:
+```xml
+
+ com.zaxxer
+ HikariCP
+ 3.4.1
+
+```
+
+* Examples:
+```java
+ public static void main(String[] args) throws SQLException {
+ HikariConfig config = new HikariConfig();
+ config.setJdbcUrl("jdbc:TAOS://127.0.0.1:6030/log");
+ config.setUsername("root");
+ config.setPassword("taosdata");
+
+ config.setMinimumIdle(3); //minimum number of idle connection
+ config.setMaximumPoolSize(10); //maximum number of connection in the pool
+ config.setConnectionTimeout(10000); //maximum wait milliseconds for get connection from pool
+ config.setIdleTimeout(60000); // max idle time for recycle idle connection
+ config.setConnectionTestQuery("describe log.dn"); //validation query
+ config.setValidationTimeout(3000); //validation query timeout
+
+ HikariDataSource ds = new HikariDataSource(config); //create datasource
+
+ Connection connection = ds.getConnection(); // get connection
+ Statement statement = connection.createStatement(); // get statement
+
+ //query or insert
+ // ...
+
+ connection.close(); // put back to conneciton pool
+}
+```
+> The close() method will not close the connection from HikariDataSource.getConnection(). Instead, the connection is put back to the connection pool.
+> More instructions can refer to [User Guide][5]
+
+**Druid**
+
+* dependency in pom.xml:
+
+```xml
+
+ com.alibaba
+ druid
+ 1.1.20
+
+```
+
+* Examples:
+```java
+public static void main(String[] args) throws Exception {
+ Properties properties = new Properties();
+ properties.put("driverClassName","com.taosdata.jdbc.TSDBDriver");
+ properties.put("url","jdbc:TAOS://127.0.0.1:6030/log");
+ properties.put("username","root");
+ properties.put("password","taosdata");
+
+ properties.put("maxActive","10"); //maximum number of connection in the pool
+ properties.put("initialSize","3");//initial number of connection
+ properties.put("maxWait","10000");//maximum wait milliseconds for get connection from pool
+ properties.put("minIdle","3");//minimum number of connection in the pool
+
+ properties.put("timeBetweenEvictionRunsMillis","3000");// the interval milliseconds to test connection
+
+ properties.put("minEvictableIdleTimeMillis","60000");//the minimum milliseconds to keep idle
+ properties.put("maxEvictableIdleTimeMillis","90000");//the maximum milliseconds to keep idle
+
+ properties.put("validationQuery","describe log.dn"); //validation query
+ properties.put("testWhileIdle","true"); // test connection while idle
+ properties.put("testOnBorrow","false"); // don't need while testWhileIdle is true
+ properties.put("testOnReturn","false"); // don't need while testWhileIdle is true
+
+ //create druid datasource
+ DataSource ds = DruidDataSourceFactory.createDataSource(properties);
+ Connection connection = ds.getConnection(); // get connection
+ Statement statement = connection.createStatement(); // get statement
+
+ //query or insert
+ // ...
+
+ connection.close(); // put back to conneciton pool
+}
+```
+> More instructions can refer to [User Guide][6]
+
+**Notice**
+* TDengine `v1.6.4.1` provides a function `select server_status()` to check heartbeat. It is highly recommended to use this function for `Validation Query`.
+
+As follows,`1` will be returned if `select server_status()` is successfully executed。
+```shell
+taos> select server_status();
+server_status()|
+================
+1 |
+Query OK, 1 row(s) in set (0.000141s)
+```
+
+## Integrated with framework
+
+* Please refer to [SpringJdbcTemplate][11] if using taos-jdbcdriver in Spring JdbcTemplate
+* Please refer to [springbootdemo][12] if using taos-jdbcdriver in Spring JdbcTemplate
+
+## FAQ
+
+* java.lang.UnsatisfiedLinkError: no taos in java.library.path
+
+ **Cause**:The application program cannot find Library function _taos_
+
+ **Answer**:Copy `C:\TDengine\driver\taos.dll` to `C:\Windows\System32\` on Windows and make a soft link through ` ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` on Linux.
+
+* java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
+
+ **Cause**:Currently TDengine only support 64bit JDK
+
+ **Answer**:re-install 64bit JDK.
+
+* For other questions, please refer to [Issues][7]
-All the error codes and error messages can be found in `TSDBError.java` . For a more detailed coding example, please refer to the demo project `JDBCDemo` in TDengine's code examples.
## Python Connector
@@ -633,3 +869,17 @@ An example of using the NodeJS connector to create a table with weather data and
An example of using the NodeJS connector to achieve the same things but without all the object wrappers that wrap around the data returned to achieve higher functionality can be found [here](https://github.com/taosdata/TDengine/tree/master/tests/examples/nodejs/node-example-raw.js)
+[1]: https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver
+[2]: https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver
+[3]: https://github.com/taosdata/TDengine
+[4]: https://www.taosdata.com/blog/2019/12/03/jdbcdriver%e6%89%be%e4%b8%8d%e5%88%b0%e5%8a%a8%e6%80%81%e9%93%be%e6%8e%a5%e5%ba%93/
+[5]: https://github.com/brettwooldridge/HikariCP
+[6]: https://github.com/alibaba/druid
+[7]: https://github.com/taosdata/TDengine/issues
+[8]: https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver
+[9]: https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver
+[10]: https://maven.aliyun.com/mvn/search
+[11]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/SpringJdbcTemplate
+[12]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/springbootdemo
+[13]: https://www.taosdata.com/cn/documentation/administrator/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E9%85%8D%E7%BD%AE
+
diff --git a/documentation/webdocs/markdowndocs/connector-ch.md b/documentation/webdocs/markdowndocs/connector-ch.md
index 82aa33d7dcef3ebb3ef3937b696b06a4022bbef0..1e2e3b698914b216ce38459464980f0327f4dc53 100644
--- a/documentation/webdocs/markdowndocs/connector-ch.md
+++ b/documentation/webdocs/markdowndocs/connector-ch.md
@@ -270,7 +270,7 @@ Connection conn = DriverManager.getConnection(jdbcUrl);
> 端口 6030 为默认连接端口,JDBC URL 中的 log 为系统本身的监控数据库。
TDengine 的 JDBC URL 规范格式为:
-`jdbc:TSDB://{host_ip}:{port}/{database_name}?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
+`jdbc:TSDB://{host_ip}:{port}/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
其中,`{}` 中的内容必须,`[]` 中为可选。配置参数说明如下:
@@ -317,6 +317,7 @@ public Connection getConn() throws Exception{
# system locale
# locale en_US.UTF-8
```
+> 更多详细配置请参考[客户端配置][13]
### 创建数据库和表
@@ -408,7 +409,7 @@ conn.close();
Statement statement = connection.createStatement(); // get statement
//query or insert
- //
+ // ...
connection.close(); // put back to conneciton pool
}
@@ -1046,30 +1047,30 @@ https://gitee.com/maikebing/Maikebing.EntityFrameworkCore.Taos
```
├── cfg
-│ └── taos.cfg
+├───└── taos.cfg
├── connector
-│ ├── go
-│ ├── grafana
-│ ├── jdbc
-│ └── python
+├───├── go
+├───├── grafana
+├───├── jdbc
+├───└── python
├── driver
-│ ├── taos.dll
-│ ├── taos.exp
-│ └── taos.lib
+├───├── taos.dll
+├───├── taos.exp
+├───└── taos.lib
├── examples
-│ ├── bash
-│ ├── c
-│ ├── C#
-│ ├── go
-│ ├── JDBC
-│ ├── lua
-│ ├── matlab
-│ ├── nodejs
-│ ├── python
-│ ├── R
-│ └── rust
+├───├── bash
+├───├── c
+├───├── C#
+├───├── go
+├───├── JDBC
+├───├── lua
+├───├── matlab
+├───├── nodejs
+├───├── python
+├───├── R
+├───└── rust
├── include
-│ └── taos.h
+├───└── taos.h
└── taos.exe
```
@@ -1125,4 +1126,5 @@ TDengine在Window系统上提供的API与Linux系统是相同的, 应用程序
[9]: https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver
[10]: https://maven.aliyun.com/mvn/search
[11]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/SpringJdbcTemplate
-[12]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/springbootdemo
\ No newline at end of file
+[12]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/springbootdemo
+[13]: https://www.taosdata.com/cn/documentation/administrator/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E9%85%8D%E7%BD%AE
diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c
index 71f983dadbe243e78330ea7f8d361bb5712f449e..2f1bcc522a1e98db303873ac8323a64c8deccf81 100644
--- a/src/client/src/TSDBJNIConnector.c
+++ b/src/client/src/TSDBJNIConnector.c
@@ -239,7 +239,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
jbyteArray jsql, jlong con) {
TAOS *tscon = (TAOS *)con;
if (tscon == NULL) {
- jniError("jobj:%p, connection is closed", jobj);
+ jniError("jobj:%p, connection is already closed", jobj);
return JNI_CONNECTION_NULL;
}
@@ -252,6 +252,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
char *dst = (char *)calloc(1, sizeof(char) * (len + 1));
if (dst == NULL) {
+ jniError("jobj:%p, conn:%p, can not alloc memory", jobj, tscon);
return JNI_OUT_OF_MEMORY;
}
@@ -260,9 +261,11 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
//todo handle error
}
+ jniTrace("jobj:%p, conn:%p, sql:%s", jobj, tscon, dst);
+
int code = taos_query(tscon, dst);
if (code != 0) {
- jniError("jobj:%p, conn:%p, code:%d, msg:%s, sql:%s", jobj, tscon, code, taos_errstr(tscon), dst);
+ jniError("jobj:%p, conn:%p, code:%d, msg:%s", jobj, tscon, code, taos_errstr(tscon));
free(dst);
return JNI_TDENGINE_ERROR;
} else {
@@ -271,9 +274,9 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
if (pSql->cmd.command == TSDB_SQL_INSERT) {
affectRows = taos_affected_rows(tscon);
- jniTrace("jobj:%p, conn:%p, code:%d, affect rows:%d, sql:%s", jobj, tscon, code, affectRows, dst);
+ jniTrace("jobj:%p, conn:%p, code:%d, affect rows:%d", jobj, tscon, code, affectRows);
} else {
- jniTrace("jobj:%p, conn:%p, code:%d, sql:%s", jobj, tscon, code, dst);
+ jniTrace("jobj:%p, conn:%p, code:%d", jobj, tscon, code);
}
free(dst);
@@ -307,7 +310,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp(
if (tscIsUpdateQuery(tscon)) {
ret = 0; // for update query, no result pointer
- jniTrace("jobj:%p, conn:%p, no result", jobj, tscon);
+ jniTrace("jobj:%p, conn:%p, no resultset", jobj, tscon);
} else {
ret = (jlong) taos_use_result(tscon);
jniTrace("jobj:%p, conn:%p, get resultset:%p", jobj, tscon, (void *) ret);
@@ -496,7 +499,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeConnectionIm
jlong con) {
TAOS *tscon = (TAOS *)con;
if (tscon == NULL) {
- jniError("jobj:%p, connection is closed", jobj);
+ jniError("jobj:%p, connection is already closed", jobj);
return JNI_CONNECTION_NULL;
} else {
jniTrace("jobj:%p, conn:%p, close connection success", jobj, tscon);
@@ -675,4 +678,4 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getTsCharset(JNIEnv *env, jobject jobj) {
return (*env)->NewStringUTF(env, (const char *)tsCharset);
-}
\ No newline at end of file
+}
diff --git a/src/client/src/tscAst.c b/src/client/src/tscAst.c
index 003a3aaf7a8bfef56954a0821746271ec6f8a799..a06a07524828aede3378e3f5487d729b1e8326a8 100644
--- a/src/client/src/tscAst.c
+++ b/src/client/src/tscAst.c
@@ -113,7 +113,6 @@ static tSQLSyntaxNode *tSQLSyntaxNodeCreate(SSchema *pSchema, int32_t numOfCols,
if (pToken->type == TK_ID || pToken->type == TK_TBNAME) {
int32_t i = 0;
-
if (pToken->type == TK_ID) {
do {
size_t len = strlen(pSchema[i].name);
@@ -936,4 +935,4 @@ void tQueryResultClean(tQueryResultset *pRes) {
tfree(pRes->pRes);
pRes->num = 0;
-}
\ No newline at end of file
+}
diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c
index 98dd00b1df4f8077b27fd7349e2addcb8715248f..d4ab40b4c7bd049c92eb97612fcff089a7370232 100644
--- a/src/client/src/tscParseInsert.c
+++ b/src/client/src/tscParseInsert.c
@@ -447,7 +447,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
tmpTokenBuf[j] = sToken.z[i];
j++;
}
-
+ tmpTokenBuf[j] = 0;
sToken.z = tmpTokenBuf;
sToken.n -= 2 + cnt;
}
diff --git a/src/connector/jdbc/readme.md b/src/connector/jdbc/readme.md
index 436e37b8064ef0946d4c989e0089eab23a2a4ab1..e81f078c153046265cbe9a856f7b48e26fc071fc 100644
--- a/src/connector/jdbc/readme.md
+++ b/src/connector/jdbc/readme.md
@@ -83,7 +83,7 @@ Connection conn = DriverManager.getConnection(jdbcUrl);
> 端口 6030 为默认连接端口,JDBC URL 中的 log 为系统本身的监控数据库。
TDengine 的 JDBC URL 规范格式为:
-`jdbc:TSDB://{host_ip}:{port}/{database_name}?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
+`jdbc:TSDB://{host_ip}:{port}/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
其中,`{}` 中的内容必须,`[]` 中为可选。配置参数说明如下:
@@ -130,6 +130,7 @@ public Connection getConn() throws Exception{
# system locale
# locale en_US.UTF-8
```
+> 更多详细配置请参考[客户端配置][13]
### 创建数据库和表
@@ -221,7 +222,7 @@ conn.close();
Statement statement = connection.createStatement(); // get statement
//query or insert
- //
+ // ...
connection.close(); // put back to conneciton pool
}
@@ -324,4 +325,5 @@ Query OK, 1 row(s) in set (0.000141s)
[9]: https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver
[10]: https://maven.aliyun.com/mvn/search
[11]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/SpringJdbcTemplate
-[12]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/springbootdemo
\ No newline at end of file
+[12]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/springbootdemo
+[13]: https://www.taosdata.com/cn/documentation/administrator/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E9%85%8D%E7%BD%AE
\ No newline at end of file
diff --git a/src/modules/http/src/httpHandle.c b/src/modules/http/src/httpHandle.c
index c736825b3750d67a92dd43624ab4383ae1f1af34..b46fa11cde6cdf93bba737ccbc223f0f9de910be 100644
--- a/src/modules/http/src/httpHandle.c
+++ b/src/modules/http/src/httpHandle.c
@@ -279,8 +279,7 @@ bool httpReadChunkedBody(HttpContext* pContext, HttpParser* pParser) {
httpParseChunkedBody(pContext, pParser, false);
return HTTP_CHECK_BODY_SUCCESS;
} else {
- httpTrace("context:%p, fd:%d, ip:%s, chunked body not finished, continue read", pContext, pContext->fd,
- pContext->ipstr);
+ httpTrace("context:%p, fd:%d, ip:%s, chunked body not finished, continue read", pContext, pContext->fd, pContext->ipstr);
if (!httpReadDataImp(pContext)) {
httpError("context:%p, fd:%d, ip:%s, read chunked request error", pContext, pContext->fd, pContext->ipstr);
return HTTP_CHECK_BODY_ERROR;
diff --git a/src/modules/http/src/httpServer.c b/src/modules/http/src/httpServer.c
index 01d3ef40f2d5a82821842e0b27c2e648d52bf237..232119b32a741e66fb3aee4d78f5df83d2a029d3 100644
--- a/src/modules/http/src/httpServer.c
+++ b/src/modules/http/src/httpServer.c
@@ -101,7 +101,7 @@ void httpFreeContext(HttpServer *pServer, HttpContext *pContext) {
void httpCleanUpContextTimer(HttpContext *pContext) {
if (pContext->timer != NULL) {
taosTmrStopA(&pContext->timer);
- httpTrace("context:%p, ip:%s, close timer:%p", pContext, pContext->ipstr, pContext->timer);
+ //httpTrace("context:%p, ip:%s, close timer:%p", pContext, pContext->ipstr, pContext->timer);
pContext->timer = NULL;
}
}
@@ -329,8 +329,6 @@ bool httpReadDataImp(HttpContext *pContext) {
}
pParser->buffer[pParser->bufsize] = 0;
- httpTrace("context:%p, fd:%d, ip:%s, thread:%s, read size:%d",
- pContext, pContext->fd, pContext->ipstr, pContext->pThread->label, pParser->bufsize);
return true;
}
@@ -383,10 +381,12 @@ bool httpReadData(HttpThread *pThread, HttpContext *pContext) {
int ret = httpCheckReadCompleted(pContext);
if (ret == HTTP_CHECK_BODY_CONTINUE) {
taosTmrReset(httpCloseContextByServerForExpired, HTTP_EXPIRED_TIME, pContext, pThread->pServer->timerHandle, &pContext->timer);
- httpTrace("context:%p, fd:%d, ip:%s, not finished yet, try another times, timer:%p", pContext, pContext->fd, pContext->ipstr, pContext->timer);
+ //httpTrace("context:%p, fd:%d, ip:%s, not finished yet, try another times, timer:%p", pContext, pContext->fd, pContext->ipstr, pContext->timer);
return false;
} else if (ret == HTTP_CHECK_BODY_SUCCESS){
httpCleanUpContextTimer(pContext);
+ httpTrace("context:%p, fd:%d, ip:%s, thread:%s, read size:%d, dataLen:%d",
+ pContext, pContext->fd, pContext->ipstr, pContext->pThread->label, pContext->parser.bufsize, pContext->parser.data.len);
if (httpDecompressData(pContext)) {
return true;
} else {