JNI ERROR (2354): JNI connection is NULL when I use JDBC to connect TDengine

JNI ERROR (2354): JNI connection is NULL when I use JDBC to connect TDengine

我正在开发一个项目,使用 Windows 中的 JDBC 连接到 Linux 上的 TDengine 数据库 运行。

配置如下:

spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver
spring.datasource.url=jdbc:TAOS://192.168.2.58:6030/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
spring.datasource.username=root
spring.datasource.password=taosdata

我也调查了TDengine的日志

06/29 18:29:30.630000 00018224 TSC starting to initialize TAOS client ...
06/29 18:29:30.630000 00018224 TSC Local End Point is:DESKTOP-PEO5CFV:6030
06/29 18:29:30.630000 00018224 UTL tsc scheduler is initialized, numOfThreads:6
06/29 18:29:30.630000 00018224 TMR ttimer monotonic clock source:POSIX clock_gettime
06/29 18:29:30.630000 00018224 UTL tmr scheduler is initialized, numOfThreads:1
06/29 18:29:30.631000 00018224 TSC TableMeta:0000016FE156BF40
06/29 18:29:30.631000 00018224 TSC client is initialized successfully
06/29 18:29:30.631000 00018224 UTL pool:0000016FE16D1CB0 is setup, maxId:5000
06/29 18:29:30.631000 00018224 TMR ttimer monotonic clock source:POSIX clock_gettime
06/29 18:29:30.631000 00018224 UTL open udp socket:0x0:0
06/29 18:29:30.631000 00018224 UTL open udp socket:0x0:0
06/29 18:29:30.631000 00018224 UTL open udp socket:0x0:0
06/29 18:29:30.631000 00018224 UTL open udp socket:0x0:0
06/29 18:29:30.631000 00016360 RPC TSC UDP thread is created, index:1
06/29 18:29:30.631000 00004944 RPC TSC UDP thread is created, index:0
06/29 18:29:30.631000 00018224 UTL open udp socket:0x0:0
06/29 18:29:30.631000 00016308 RPC TSC UDP thread is created, index:2
06/29 18:29:30.631000 00018224 UTL open udp socket:0x0:0
06/29 18:29:30.631000 00011648 RPC TSC UDP thread is created, index:3
06/29 18:29:30.631000 00018224 RPC TSC UDP connection is initialized, ip:0:0 threads:6
06/29 18:29:30.631000 00018224 RPC TSC rpc is opened, threads:6 sessions:5000
06/29 18:29:30.631000 00008320 RPC TSC UDP thread is created, index:4
06/29 18:29:30.631000 00018224 UTL cache:rpcObj, key:00000017E0BFA2A0, 0000016FE14D6C50 added into cache, added:1624962570631, expire:1624962575631, totalNum:1 totalSize:617bytes size:520bytes
06/29 18:29:30.631000 00018224 TSC 0000016FE1A401E0 new SqlObj from 0000016FE19F3950, total in tscObj:1, total:1
06/29 18:29:30.631000 00018224 TSC 0000016FE1A401E0 SQL cmd:connect will be processed, name:, type:0
06/29 18:29:30.631000 00000868 RPC TSC UDP thread is created, index:5
06/29 18:29:30.631000 00018224 RPC TSC 0000016FE3DE81B8 client connection is allocated, uid:0xe3df2b5e
06/29 18:29:30.631000 00018224 RPC TSC UDP connection is setup, ip:6cdf6527:6030 localPort:63914
06/29 18:29:30.631000 00018224 RPC TSC 0000016FE3DE81B8 0000000000000002, connect is sent to 39.101.223.108:6030, len:377 sig:0x01000000:0x00000000:26895
06/29 18:29:31.636000 00019936 RPC TSC 0000016FE3DE81B8 0000000000000002, expected connect-rsp is not received
06/29 18:29:31.636000 00019936 RPC TSC 0000016FE3DE81B8 0000000000000002, re-send msg:connect to 39.101.223.108:6030
06/29 18:29:31.636000 00019936 RPC TSC 0000016FE3DE81B8 0000000000000002, connect is sent to 39.101.223.108:6030, len:377 sig:0x01000000:0x00000000:26895
06/29 18:29:32.641000 00019936 RPC TSC 0000016FE3DE81B8 0000000000000002, expected connect-rsp is not received
06/29 18:29:32.641000 00019936 RPC TSC 0000016FE3DE81B8 0000000000000002, re-send msg:connect to 39.101.223.108:6030
06/29 18:29:32.641000 00019936 RPC TSC 0000016FE3DE81B8 0000000000000002, connect is sent to 39.101.223.108:6030, len:377 sig:0x01000000:0x00000000:26895
06/29 18:29:33.646000 00019936 RPC TSC 0000016FE3DE81B8 0000000000000002, expected connect-rsp is not received
06/29 18:29:33.646000 00019936 RPC TSC 0000016FE3DE81B8 0000000000000002, re-send msg:connect to 39.101.223.108:6030
06/29 18:29:33.646000 00019936 RPC TSC 0000016FE3DE81B8 0000000000000002, connect is sent to 39.101.223.108:6030, len:377 sig:0x01000000:0x00000000:26895

我不知道发生了什么。有人可以提示如何解决吗?

这个异常一般是由于网络配置,客户端时区与服务器客户端不匹配导致的。 尝试使用taos客户端连接服务器

在您的 JDBC 连接字符串中,使用主机名而不是 IP 地址:

jdbc:TAOS://DESKTOP-PEO5CFV:6030/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8

多半是客户端和服务器版本不一致导致的。在我看来,TDengine 不支持向后兼容。您必须确保客户端版本(即 java.library.path 中下载的 libtaos.so,例如 /usr/lib)与服务器版本完全匹配。

我尝试使用客户端版本 2.0.22.0。它不适用于服务器 2.2 或 2.4。我必须将服务器降级回 2.0.22.0。

如果您 运行 TDengine 与 docker,您最好在图像中使用特定标签而不是默认的 'latest',例如 tdengine/tdengine:2.0。 22.0.