TDengine icon indicating copy to clipboard operation
TDengine copied to clipboard

JNI ERROR (2354): JNI connection is NULL

Open cxntsh opened this issue 5 years ago • 16 comments

Bug Description

JDBCDemo project run error The sample project from client installation package

error info:

[root@localhost home]# java -jar JDBCDemo.jar -host 127.0.0.1 get connection starting... java.library.path:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

java.sql.SQLException: JNI ERROR (2354): JNI connection is NULL
	at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:64)
	at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:48)
	at com.taosdata.jdbc.TSDBJNIConnector.connect(TSDBJNIConnector.java:105)
	at com.taosdata.jdbc.TSDBConnection.connect(TSDBConnection.java:50)
	at com.taosdata.jdbc.TSDBConnection.<init>(TSDBConnection.java:36)
	at com.taosdata.jdbc.TSDBDriver.connect(TSDBDriver.java:121)
	at java.sql.DriverManager.getConnection(DriverManager.java:674)
	at java.sql.DriverManager.getConnection(DriverManager.java:217)
	at com.taosdata.example.JDBCDemo.init(JDBCDemo.java:42)
	at com.taosdata.example.JDBCDemo.main(JDBCDemo.java:21)
Exception in thread "main" java.lang.NullPointerException
	at com.taosdata.example.JDBCDemo.exuete(JDBCDemo.java:123)
	at com.taosdata.example.JDBCDemo.createDatabase(JDBCDemo.java:52)
	at com.taosdata.example.JDBCDemo.main(JDBCDemo.java:22)

This kind of error will appear on both windows platform and Linux !!!

Environment (please complete the following information):

  • OS: [e.g. CentOS 7.0]
  • Memory, CPU, current Disk Space
  • TDengine Version 2.0.18

cxntsh avatar Mar 22 '21 12:03 cxntsh

Is it ok to connect with client?

cpvmrd avatar Mar 22 '21 14:03 cpvmrd

Please refer to https://github.com/taosdata/TDengine/issues/5395.

cpvmrd avatar Mar 22 '21 14:03 cpvmrd

Is it ok to connect with client?

There is no problem using client to connect

cxntsh avatar Mar 22 '21 15:03 cxntsh

Is it ok to connect with client?

There is no problem using client to connect

问题描述里写的是运行JDBCDemo那个包报错,和配置文件没关系,因为JDBCDemo里面指定了要连接的ep。你的这个问题和#5395没关系。

你的报错:JNI:connection is null还是需要你检查fqdn配置等。把taos shell连接成功的截图贴出来

zyyang90 avatar Mar 23 '21 01:03 zyyang90

Is it ok to connect with client?

There is no problem using client to connect

问题描述里写的是运行JDBCDemo那个包报错,和配置文件没关系,因为JDBCDemo里面指定了要连接的ep。你的这个问题和#5395没关系。

你的报错:JNI:connection is null还是需要你检查fqdn配置等。把taos shell连接成功的截图贴出来

Linux:

[root@localhost home]# java -jar JDBCDemo.jar -host 172.16.3.133
get connection starting...
java.library.path:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
[ OK ] Connection established.
[ ERROR! ] time cost: 3 ms, execute statement ====> create database if not exists test
[ ERROR! ] time cost: 0 ms, execute statement ====> use test
[ ERROR! ] time cost: 1 ms, execute statement ====> drop table if exists test.weather
[ ERROR! ] time cost: 7 ms, execute statement ====> create table if not exists test.weather (ts timestamp, temperature float, humidity int)
[ ERROR! ] time cost: 2 ms, execute statement ====> insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)
[ OK ] time cost: 5 ms, execute statement ====> select * from test.weather
ts: 1616467570486	temperature: 20.5	humidity: 34	
[ ERROR! ] time cost: 4 ms, execute statement ====> drop table if exists test.weather
connection closed.

Windows:

[ OK ] Connection established.
[ ERROR! ] time cost: 17 ms, execute statement ====> create database if not exists test
[ ERROR! ] time cost: 12 ms, execute statement ====> use test
[ ERROR! ] time cost: 11 ms, execute statement ====> drop table if exists test.weather
[ ERROR! ] time cost: 23 ms, execute statement ====> create table if not exists test.weather (ts timestamp, temperature float, humidity int)
java.sql.SQLException: TDengine ERROR (8000000b): Unable to establish connection
	at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:65)
	at com.taosdata.jdbc.TSDBJNIConnector.executeQuery(TSDBJNIConnector.java:153)
	at com.taosdata.jdbc.TSDBStatement.execute(TSDBStatement.java:88)
	at com.taosdata.example.JDBCDemo.exuete(JDBCDemo.java:125)
	at com.taosdata.example.JDBCDemo.insert(JDBCDemo.java:72)
	at com.taosdata.example.JDBCDemo.main(JDBCDemo.java:26)
java.sql.SQLException: TDengine ERROR (8000000b): Unable to establish connection
	at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:65)
	at com.taosdata.jdbc.TSDBJNIConnector.executeQuery(TSDBJNIConnector.java:153)
	at com.taosdata.jdbc.TSDBStatement.executeQuery(TSDBStatement.java:48)
	at com.taosdata.example.JDBCDemo.executeQuery(JDBCDemo.java:96)
	at com.taosdata.example.JDBCDemo.select(JDBCDemo.java:77)
	at com.taosdata.example.JDBCDemo.main(JDBCDemo.java:27)
[ ERROR! ] time cost: 7 ms, execute statement ====> drop table if exists test.weather
connection closed.

指定 firstEp 以后,的确可以连接,但是两个平台会有不同的结果

cxntsh avatar Mar 23 '21 02:03 cxntsh

还是你配置的问题,你把server的firstEp你怎么配置的,贴出来

zyyang90 avatar Mar 23 '21 03:03 zyyang90

还是你配置的问题,你把server的firstEp你怎么配置的,贴出来

Centos7 Servert cfg:

[root@localhost home]# cd /etc/taos/
[root@localhost taos]# ll
total 8
-rw-r--r-- 1 root root 7946 Mar 23 10:44 taos.cfg
[root@localhost taos]# vim taos.cfg 

########################################################
#                                                      #
#                  TDengine Configuration              #
#   Any questions, please email [email protected]   #
#                                                      #
########################################################

# first fully qualified domain name (FQDN) for TDengine system
firstEp                   172.16.3.133:6030

# local fully qualified domain name (FQDN)
# fqdn                      hostname

# first port number for the connection (12 continuous UDP/TCP port number are used) 
# serverPort                6030

cxntsh avatar Mar 23 '21 03:03 cxntsh

还是你配置的问题,你把server的firstEp你怎么配置的,贴出来

Centos7 Servert cfg:

[root@localhost home]# cd /etc/taos/
[root@localhost taos]# ll
total 8
-rw-r--r-- 1 root root 7946 Mar 23 10:44 taos.cfg
[root@localhost taos]# vim taos.cfg 

########################################################
#                                                      #
#                  TDengine Configuration              #
#   Any questions, please email [email protected]   #
#                                                      #
########################################################

# first fully qualified domain name (FQDN) for TDengine system
firstEp                   172.16.3.133:6030

# local fully qualified domain name (FQDN)
# fqdn                      hostname

# first port number for the connection (12 continuous UDP/TCP port number are used) 
# serverPort                6030

是的,你在server上用hostname看一下,你server的hostname是什么,这个firstEp就应该是你的hostname:6030,fqdn就应该是hostname,修改后重启server的taosd。 在client端,检查使用通过hostname可以ping通server。如果ping不通,在client上执行: echo "your_hostname your_ip" >> /etc/hosts, 把server的hostname写入的client的hosts文件,然后重新跑应用连接。

zyyang90 avatar Mar 23 '21 03:03 zyyang90

还是你配置的问题,你把server的firstEp你怎么配置的,贴出来

Centos7 Servert cfg:

[root@localhost home]# cd /etc/taos/
[root@localhost taos]# ll
total 8
-rw-r--r-- 1 root root 7946 Mar 23 10:44 taos.cfg
[root@localhost taos]# vim taos.cfg 

########################################################
#                                                      #
#                  TDengine Configuration              #
#   Any questions, please email [email protected]   #
#                                                      #
########################################################

# first fully qualified domain name (FQDN) for TDengine system
firstEp                   172.16.3.133:6030

# local fully qualified domain name (FQDN)
# fqdn                      hostname

# first port number for the connection (12 continuous UDP/TCP port number are used) 
# serverPort                6030

是的,你在server上用hostname看一下,你server的hostname是什么,这个firstEp就应该是你的hostname:6030,fqdn就应该是hostname,修改后重启server的taosd。 在client端,检查使用通过hostname可以ping通server。如果ping不通,在client上执行: echo "your_hostname your_ip" >> /etc/hosts, 把server的hostname写入的client的hosts文件,然后重新跑应用连接。

这是本地 Windows 10 C:\TDengine\cfg 配置文件:

# first fully qualified domain name (FQDN) for TDengine system
firstEp                   node1:6030

# local fully qualified domain name (FQDN)
fqdn                      node1

Centos7 server 端配置:

# first fully qualified domain name (FQDN) for TDengine system
firstEp                   node1:6030

# local fully qualified domain name (FQDN)
fqdn                      node1
[root@node1 home]# hostname -f
node1

/etc/hosts 文件:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.3.133 node1

Windows10 ping node1

PS C:\TDengine> ping node1

正在 Ping node1 [172.16.3.133] 具有 32 字节的数据:
来自 172.16.3.133 的回复: 字节=32 时间=127ms TTL=64
来自 172.16.3.133 的回复: 字节=32 时间=10ms TTL=64
来自 172.16.3.133 的回复: 字节=32 时间=16ms TTL=64
来自 172.16.3.133 的回复: 字节=32 时间=119ms TTL=64

说明 hosts 文件已经生效。

Windows10 Client 客户端直连

PS C:\TDengine> .\taos.exe -h node1 -u root -p

Welcome to the TDengine shell from Linux, Client Version:2.0.18.0
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.

Enter password: taos connect failed, reason: Unable to establish connection.

Idea 工具运行 JDBCDemo : -host node1 或者 -host 172.16.3.133 结果都如下

java.sql.SQLException: JNI ERROR (2354): JNI connection is NULL
	at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:72)
	at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:56)
	at com.taosdata.jdbc.TSDBJNIConnector.connect(TSDBJNIConnector.java:110)
	at com.taosdata.jdbc.TSDBConnection.connect(TSDBConnection.java:50)
	at com.taosdata.jdbc.TSDBConnection.<init>(TSDBConnection.java:36)
	at com.taosdata.jdbc.TSDBDriver.connect(TSDBDriver.java:123)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:189)
	at com.taosdata.example.JDBCDemo.init(JDBCDemo.java:42)
	at com.taosdata.example.JDBCDemo.main(JDBCDemo.java:21)
Exception in thread "main" java.lang.NullPointerException
	at com.taosdata.example.JDBCDemo.exuete(JDBCDemo.java:123)
	at com.taosdata.example.JDBCDemo.createDatabase(JDBCDemo.java:52)
	at com.taosdata.example.JDBCDemo.main(JDBCDemo.java:22)

Process finished with exit code 1

Cenos7 Server 端 jar -jar : -host node1 和 -host 172.16.3.133 都是如下结果

[root@node1 home]# java -jar JDBCDemo.jar -host node1
get connection starting...
java.library.path:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
[ OK ] Connection established.
[ ERROR! ] time cost: 2 ms, execute statement ====> create database if not exists test
[ ERROR! ] time cost: 1 ms, execute statement ====> use test
[ ERROR! ] time cost: 2 ms, execute statement ====> drop table if exists test.weather
[ ERROR! ] time cost: 13 ms, execute statement ====> create table if not exists test.weather (ts timestamp, temperature float, humidity int)
[ ERROR! ] time cost: 1 ms, execute statement ====> insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)
[ OK ] time cost: 6 ms, execute statement ====> select * from test.weather
ts: 1616480240755	temperature: 20.5	humidity: 34	
[ ERROR! ] time cost: 3 ms, execute statement ====> drop table if exists test.weather
connection closed.

cxntsh avatar Mar 23 '21 06:03 cxntsh

你把windows那边的C:\TDengine\cfg\taos.cfg内的debugflag设置成135,清空日志目录C:\TDengine\log,重新跑你的java应用,然后看C:\TDengine\log\taoslog0.0这个日志文件,在里面搜ERROR。检查集体是什么问题。

从你的描述来看,我认为是你之前在server使用其他的hostname启动了taosd示例。如果你的数据并不重要,可以考虑删除掉之前的数据文件,并重启taosd。

zyyang90 avatar Mar 23 '21 06:03 zyyang90

你把windows那边的C:\TDengine\cfg\taos.cfg内的debugflag设置成135,清空日志目录C:\TDengine\log,重新跑你的java应用,然后看C:\TDengine\log\taoslog0.0这个日志文件,在里面搜ERROR。检查集体是什么问题。

从你的描述来看,我认为是你之前在server使用其他的hostname启动了taosd示例。如果你的数据并不重要,可以考虑删除掉之前的数据文件,并重启taosd。

==================================================
                new log file                      
==================================================
03/23 14:52:22.436000 00017280 UTL all debug flag are set to 135
03/23 14:52:22.436000 00017280 UTL all debug flag are set to 135
03/23 14:52:22.447000 00017280 UTL localEp is: DESKTOP-EVKDIIO:6030
03/23 14:52:22.447000 00017280 UTL    check global cfg completed
03/23 14:52:22.447000 00017280 UTL ==================================
03/23 14:52:22.447000 00017280 UTL    taos config & system info:
03/23 14:52:22.447000 00017280 UTL ==================================
03/23 14:52:22.447000 00017280 UTL  firstEp:                node1:6030 
03/23 14:52:22.447000 00017280 UTL  secondEp:               DESKTOP-EVKDIIO:6030 
03/23 14:52:22.447000 00017280 UTL  fqdn:                   DESKTOP-EVKDIIO 
03/23 14:52:22.447000 00017280 UTL  serverPort:             6030 
03/23 14:52:22.447000 00017280 UTL  configDir:              C:\TDengine\cfg 
03/23 14:52:22.447000 00017280 UTL  logDir:                 C:\TDengine\log 
03/23 14:52:22.447000 00017280 UTL  scriptDir:              C:/TDengine/script 
03/23 14:52:22.447000 00017280 UTL  arbitrator:              
03/23 14:52:22.447000 00017280 UTL  numOfThreadsPerCore:    1.000000 
03/23 14:52:22.447000 00017280 UTL  rpcTimer:               1000(ms)
03/23 14:52:22.447000 00017280 UTL  rpcMaxTime:             600(s)
03/23 14:52:22.447000 00017280 UTL  shellActivityTimer:     3(s)
03/23 14:52:22.447000 00017280 UTL  compressMsgSize:        -1 
03/23 14:52:22.447000 00017280 UTL  maxSQLLength:           65480(byte)
03/23 14:52:22.447000 00017280 UTL  maxNumOfOrderedRes:     100000 
03/23 14:52:22.447000 00017280 UTL  keepColumnName:         0 
03/23 14:52:22.447000 00017280 UTL  timezone:               (UTC, +0800) 
03/23 14:52:22.447000 00017280 UTL  locale:                 Chinese (Simplified)_China.936 
03/23 14:52:22.447000 00017280 UTL  charset:                UTF-8 
03/23 14:52:22.447000 00017280 UTL  numOfLogLines:          10000000 
03/23 14:52:22.447000 00017280 UTL  logKeepDays:            0 
03/23 14:52:22.447000 00017280 UTL  asyncLog:               1 
03/23 14:52:22.447000 00017280 UTL  debugFlag:              135 
03/23 14:52:22.447000 00017280 UTL  rpcDebugFlag:           135 
03/23 14:52:22.447000 00017280 UTL  tmrDebugFlag:           131 
03/23 14:52:22.447000 00017280 UTL  cDebugFlag:             135 
03/23 14:52:22.447000 00017280 UTL  jniDebugFlag:           135 
03/23 14:52:22.447000 00017280 UTL  odbcDebugFlag:          135 
03/23 14:52:22.447000 00017280 UTL  uDebugFlag:             135 
03/23 14:52:22.447000 00017280 UTL  qDebugFlag:             135 
03/23 14:52:22.447000 00017280 UTL  tsdbDebugFlag:          135 
03/23 14:52:22.447000 00017280 UTL  gitinfo:                no git commit id 
03/23 14:52:22.447000 00017280 UTL  gitinfoOfInternal:      156825ceec5ba5dbd982c1c8ad521979bcbf0e31 
03/23 14:52:22.447000 00017280 UTL  buildinfo:              Built at 2021-03-22 02:57:06 
03/23 14:52:22.447000 00017280 UTL  version:                2.0.18.0 
03/23 14:52:22.447000 00017280 UTL  maxBinaryDisplayWidth:  30 
03/23 14:52:22.447000 00017280 UTL  tempDir:                C:\Users\nantian\AppData\Local\Temp 
03/23 14:52:22.447000 00017280 UTL  os numOfCores:          16
03/23 14:52:22.447000 00017280 UTL  os totalDisk:           0.000000(GB)
03/23 14:52:22.447000 00017280 UTL  os usedDisk:            0.000000(GB)
03/23 14:52:22.447000 00017280 UTL  os availDisk:           0.000000(GB)
03/23 14:52:22.447000 00017280 UTL  os totalMemory:         32681(MB)
03/23 14:52:22.447000 00017280 UTL ==================================
03/23 14:52:22.447000 00017280 UTL  dataDir: C:/TDengine/data level:0 primary:1
03/23 14:52:22.447000 00017280 UTL ==================================
03/23 14:52:22.447000 00017280 TSC starting to initialize TAOS client ...
03/23 14:52:22.447000 00017280 TSC Local End Point is:DESKTOP-EVKDIIO:6030
03/23 14:52:22.447000 00017280 UTL tsc scheduler is initialized, numOfThreads:8
03/23 14:52:22.447000 00017280 TMR ttimer monotonic clock source:POSIX clock_gettime
03/23 14:52:22.447000 00017280 UTL tmr scheduler is initialized, numOfThreads:1
03/23 14:52:22.448000 00017280 TSC TableMeta:000001EFFF44A9F0
03/23 14:52:22.448000 00017280 TSC client is initialized successfully
03/23 14:52:22.448000 00017280 UTL pool:000001EFFF45F9E0 is setup, maxId:5000
03/23 14:52:22.448000 00017280 TMR ttimer monotonic clock source:POSIX clock_gettime
03/23 14:52:22.448000 00017280 UTL open udp socket:0x0:0
03/23 14:52:22.449000 00017280 UTL open udp socket:0x0:0
03/23 14:52:22.449000 00017280 UTL open udp socket:0x0:0
03/23 14:52:22.449000 00017280 UTL open udp socket:0x0:0
03/23 14:52:22.449000 00015176 RPC TSC UDP thread is created, index:0
03/23 14:52:22.449000 00017280 UTL open udp socket:0x0:0
03/23 14:52:22.449000 00011220 RPC TSC UDP thread is created, index:1
03/23 14:52:22.449000 00009780 RPC TSC UDP thread is created, index:2
03/23 14:52:22.449000 00017280 UTL open udp socket:0x0:0
03/23 14:52:22.449000 00007496 RPC TSC UDP thread is created, index:3
03/23 14:52:22.449000 00017280 UTL open udp socket:0x0:0
03/23 14:52:22.449000 00004224 RPC TSC UDP thread is created, index:4
03/23 14:52:22.449000 00017280 UTL open udp socket:0x0:0
03/23 14:52:22.449000 00010992 RPC TSC UDP thread is created, index:5
03/23 14:52:22.449000 00017280 RPC TSC UDP connection is initialized, ip:0:0 threads:8
03/23 14:52:22.449000 00017280 RPC TSC rpc is opened, threads:8 sessions:5000
03/23 14:52:22.449000 00014544 RPC TSC UDP thread is created, index:6
03/23 14:52:22.449000 00017280 UTL cache:rpcObj, key:000000E1830FE580, 000001EFFF530BA0 added into cache, added:1616482342449, expire:1616482347449, totalNum:1 totalSize:608bytes size:520bytes
03/23 14:52:22.449000 00017280 TSC 000001EFFF531070 new SqlObj from 000001EFFF478220, total in tscObj:1, total:1
03/23 14:52:22.449000 00018016 RPC TSC UDP thread is created, index:7
03/23 14:52:22.449000 00017280 TSC 000001EFFF531070 SQL cmd:connect will be processed, name:, type:0
03/23 14:52:22.450000 00017280 RPC TSC 000001EF893CA1B8 client connection is allocated, uid:0x893d446a
03/23 14:52:22.450000 00017280 RPC TSC UDP connection is setup, ip:850310ac:6030 localPort:57062
03/23 14:52:22.450000 00017280 RPC TSC 000001EF893CA1B8 0000000000000002, connect is sent to node1:6030, len:377 sig:0x01000000:0x00000000:22999
03/23 14:52:23.458000 00018108 RPC TSC 000001EF893CA1B8 0000000000000002, expected connect-rsp is not received
03/23 14:52:23.458000 00018108 RPC TSC 000001EF893CA1B8 0000000000000002, re-send msg:connect to node1:6030
03/23 14:52:23.458000 00018108 RPC TSC 000001EF893CA1B8 0000000000000002, connect is sent to node1:6030, len:377 sig:0x01000000:0x00000000:22999
03/23 14:52:24.458000 00018108 RPC TSC 000001EF893CA1B8 0000000000000002, expected connect-rsp is not received
03/23 14:52:24.458000 00018108 RPC TSC 000001EF893CA1B8 0000000000000002, re-send msg:connect to node1:6030
03/23 14:52:24.458000 00018108 RPC TSC 000001EF893CA1B8 0000000000000002, connect is sent to node1:6030, len:377 sig:0x01000000:0x00000000:22999
03/23 14:52:25.458000 00018108 RPC TSC 000001EF893CA1B8 0000000000000002, expected connect-rsp is not received
03/23 14:52:25.458000 00018108 RPC TSC 000001EF893CA1B8 0000000000000002, re-send msg:connect to node1:6030
03/23 14:52:25.458000 00018108 RPC TSC 000001EF893CA1B8 0000000000000002, connect is sent to node1:6030, len:377 sig:0x01000000:0x00000000:22999

cxntsh avatar Mar 23 '21 06:03 cxntsh

对,你这日志已经写了,在用taostaos.exe -h node1 -u root -p去连,如果报错,然后看日志里的ERROR

zyyang90 avatar Mar 23 '21 07:03 zyyang90

对,你这日志已经写了,在用taostaos.exe -h node1 -u root -p去连,如果报错,然后看日志里的ERROR

我重新用一台之前没有安装过 tdengine 的 Centos7 重新安装,安装之前已经配置 hostname 为node2,操作和之前 node1 完全一致,现在本地连,debug 135,然后日志如下:

03/23 15:10:20.364000 00009068 TSC starting to initialize TAOS client ...
03/23 15:10:20.364000 00009068 TSC Local End Point is:node2:6030
03/23 15:10:20.364000 00009068 UTL tsc scheduler is initialized, numOfThreads:8
03/23 15:10:20.364000 00009068 TMR ttimer monotonic clock source:POSIX clock_gettime
03/23 15:10:20.364000 00009068 UTL tmr scheduler is initialized, numOfThreads:1
03/23 15:10:20.365000 00009068 TSC TableMeta:0000021C6CE21810
03/23 15:10:20.365000 00009068 TSC client is initialized successfully
03/23 15:10:20.365000 00009068 TSC try to create a connection to node2:6030, user:root db:(null)
03/23 15:10:20.365000 00009068 UTL pool:0000021C6CDF30A0 is setup, maxId:5000
03/23 15:10:20.365000 00009068 TMR ttimer monotonic clock source:POSIX clock_gettime
03/23 15:10:20.365000 00009068 UTL open udp socket:0x0:0
03/23 15:10:20.366000 00009068 UTL open udp socket:0x0:0
03/23 15:10:20.366000 00009068 UTL open udp socket:0x0:0
03/23 15:10:20.366000 00020304 RPC TSC UDP thread is created, index:0
03/23 15:10:20.367000 00009068 UTL open udp socket:0x0:0
03/23 15:10:20.367000 00005952 RPC TSC UDP thread is created, index:1
03/23 15:10:20.367000 00009068 UTL open udp socket:0x0:0
03/23 15:10:20.367000 00018832 RPC TSC UDP thread is created, index:2
03/23 15:10:20.367000 00009068 UTL open udp socket:0x0:0
03/23 15:10:20.367000 00014832 RPC TSC UDP thread is created, index:3
03/23 15:10:20.367000 00009068 UTL open udp socket:0x0:0
03/23 15:10:20.367000 00013880 RPC TSC UDP thread is created, index:4
03/23 15:10:20.367000 00009068 UTL open udp socket:0x0:0
03/23 15:10:20.367000 00009120 RPC TSC UDP thread is created, index:5
03/23 15:10:20.367000 00009068 RPC TSC UDP connection is initialized, ip:0:0 threads:8
03/23 15:10:20.367000 00009068 RPC TSC rpc is opened, threads:8 sessions:5000
03/23 15:10:20.367000 00009068 UTL cache:rpcObj, key:000000DDE24FEDE0, 0000021C6CE4E350 added into cache, added:1616483420367, expire:1616483425367, totalNum:1 totalSize:605bytes size:520bytes
03/23 15:10:20.367000 00010336 RPC TSC UDP thread is created, index:6
03/23 15:10:20.367000 00009068 TSC 0000021C6CE4E8F0 new SqlObj from 0000021C6CE4E580, total in tscObj:1, total:1
03/23 15:10:20.367000 00009068 TSC 0000021C6CE4E8F0 SQL cmd:connect will be processed, name:, type:0
03/23 15:10:20.367000 00003284 RPC TSC UDP thread is created, index:7
03/23 15:10:20.374000 00009068 RPC TSC 0000021C6FE0F1B8 client connection is allocated, uid:0x6fe1a466
03/23 15:10:20.374000 00009068 RPC TSC UDP connection is setup, ip:850310ac:6030 localPort:65246
03/23 15:10:20.374000 00009068 RPC TSC 0000021C6FE0F1B8 0000000000000002, connect is sent to node2:6030, len:377 sig:0x01000000:0x00000000:26519
03/23 15:10:21.374000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, expected connect-rsp is not received
03/23 15:10:21.374000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, re-send msg:connect to node2:6030
03/23 15:10:21.374000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, connect is sent to node2:6030, len:377 sig:0x01000000:0x00000000:26519
03/23 15:10:22.374000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, expected connect-rsp is not received
03/23 15:10:22.374000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, re-send msg:connect to node2:6030
03/23 15:10:22.374000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, connect is sent to node2:6030, len:377 sig:0x01000000:0x00000000:26519
03/23 15:10:23.375000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, expected connect-rsp is not received
03/23 15:10:23.375000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, re-send msg:connect to node2:6030
03/23 15:10:23.375000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, connect is sent to node2:6030, len:377 sig:0x01000000:0x00000000:26519
03/23 15:10:24.379000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, expected connect-rsp is not received
03/23 15:10:24.379000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, failed to send msg:connect to node2:6030
03/23 15:10:24.379000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, rpc connection is released
03/23 15:10:24.384000 00017376 RPC TSC 0000000000000002, connection error happens
03/23 15:10:24.384000 00017376 TSC 0000021C6CE4E8F0 SQL cmd:connect, code:Unable to establish connection rspLen:0
03/23 15:10:24.384000 00009068 TSC 0000021C6CE4E8F0 free sqlObj in cache
03/23 15:10:24.384000 00009068 TSC 0000021C6CE4E8F0 free SqlObj, total in tscObj:0, total:0
03/23 15:10:24.384000 00009068 TSC 0000021C6CE4E8F0 start to free sqlObj
03/23 15:10:24.384000 00009068 TSC 0000021C6CE4E580 try to free tscObj
03/23 15:10:24.384000 00009068 TSC 0000021C6CE4E580 all sqlObj are freed, free tscObj
03/23 15:10:24.384000 00009068 UTL cache:rpcObj data:0000021C6CE4E350 extend expire time: 1616483429384
03/23 15:10:24.384000 00009068 UTL cache:rpcObj, key:0000021C6CE4E558, 0000021C6CE4E350 released, refcnt:0, data in trashcan:0
03/23 15:10:24.385000 00009068 TSC start to cleanup client environment

cxntsh avatar Mar 23 '21 07:03 cxntsh

03/23 15:10:24.379000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, failed to send msg:connect to node2:6030 03/23 15:10:24.384000 00017376 RPC TSC 0000000000000002, connection error happens

检查你的网络,防火墙。日志显示你建立不了到node2:6030端口的连接

zyyang90 avatar Mar 23 '21 07:03 zyyang90

03/23 15:10:24.379000 00017376 RPC TSC 0000021C6FE0F1B8 0000000000000002, failed to send msg:connect to node2:6030 03/23 15:10:24.384000 00017376 RPC TSC 0000000000000002, connection error happens

检查你的网络,防火墙。日志显示你建立不了到node2:6030端口的连接

感谢 耐心的解答,谢谢!

现在执行的结果:

[ OK ] Connection established.
[ ERROR! ] time cost: 1609 ms, execute statement ====> create database if not exists test
[ ERROR! ] time cost: 1007 ms, execute statement ====> use test
[ ERROR! ] time cost: 1385 ms, execute statement ====> drop table if exists test.weather
[ ERROR! ] time cost: 2647 ms, execute statement ====> create table if not exists test.weather (ts timestamp, temperature float, humidity int)
[ ERROR! ] time cost: 1369 ms, execute statement ====> insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)
connection closed.
Disconnected from the target VM, address: '127.0.0.1:50409', transport: 'socket'

最后的疑问: 为什么 boolean execute = statement.execute(sql); 返回的结果都是 false ?

cxntsh avatar Mar 23 '21 08:03 cxntsh

这个是JDBC API的规范,execute方法执行的SQL是一个会返回结果集ResultSet的SQL,则execute返回true,其他的都返回false。参考一下:https://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#execute-java.lang.String-

zyyang90 avatar Mar 23 '21 08:03 zyyang90