Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5131e7b1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5131e7b1
编写于
5月 12, 2021
作者:
Z
zyyang
提交者:
GitHub
5月 12, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix/td 3986 (#6088)
* [TD-3986]<fix>: fix subscribe test case error * change jdbc version number
上级
95139cf4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
45 addition
and
35 deletion
+45
-35
cmake/install.inc
cmake/install.inc
+1
-1
src/connector/jdbc/CMakeLists.txt
src/connector/jdbc/CMakeLists.txt
+1
-1
src/connector/jdbc/deploy-pom.xml
src/connector/jdbc/deploy-pom.xml
+1
-1
src/connector/jdbc/pom.xml
src/connector/jdbc/pom.xml
+1
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+3
-12
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
+8
-5
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
...r/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
+30
-14
未找到文件。
cmake/install.inc
浏览文件 @
5131e7b1
...
...
@@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF
(
TD_MVN_INSTALLED
)
INSTALL
(
FILES
$
{
LIBRARY_OUTPUT_PATH
}
/
taos
-
jdbcdriver
-
2.0.2
8
-
dist
.
jar
DESTINATION
connector
/
jdbc
)
INSTALL
(
FILES
$
{
LIBRARY_OUTPUT_PATH
}
/
taos
-
jdbcdriver
-
2.0.2
9
.
jar
DESTINATION
connector
/
jdbc
)
ENDIF
()
ELSEIF
(
TD_DARWIN
)
SET
(
TD_MAKE_INSTALL_SH
"${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh"
)
...
...
src/connector/jdbc/CMakeLists.txt
浏览文件 @
5131e7b1
...
...
@@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
ADD_CUSTOM_COMMAND
(
OUTPUT
${
JDBC_CMD_NAME
}
POST_BUILD
COMMAND mvn -Dmaven.test.skip=true install -f
${
CMAKE_CURRENT_SOURCE_DIR
}
/pom.xml
COMMAND
${
CMAKE_COMMAND
}
-E copy
${
CMAKE_CURRENT_SOURCE_DIR
}
/target/taos-jdbcdriver-2.0.2
8-dist
.jar
${
LIBRARY_OUTPUT_PATH
}
COMMAND
${
CMAKE_COMMAND
}
-E copy
${
CMAKE_CURRENT_SOURCE_DIR
}
/target/taos-jdbcdriver-2.0.2
9
.jar
${
LIBRARY_OUTPUT_PATH
}
COMMAND mvn -Dmaven.test.skip=true clean -f
${
CMAKE_CURRENT_SOURCE_DIR
}
/pom.xml
COMMENT
"build jdbc driver"
)
ADD_CUSTOM_TARGET
(
${
JDBC_TARGET_NAME
}
ALL WORKING_DIRECTORY
${
EXECUTABLE_OUTPUT_PATH
}
DEPENDS
${
JDBC_CMD_NAME
}
)
...
...
src/connector/jdbc/deploy-pom.xml
浏览文件 @
5131e7b1
...
...
@@ -5,7 +5,7 @@
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.2
8
</version>
<version>
2.0.2
9
</version>
<packaging>
jar
</packaging>
<name>
JDBCDriver
</name>
...
...
src/connector/jdbc/pom.xml
浏览文件 @
5131e7b1
...
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.2
8
</version>
<version>
2.0.2
9
</version>
<packaging>
jar
</packaging>
<name>
JDBCDriver
</name>
<url>
https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc
</url>
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
5131e7b1
...
...
@@ -32,7 +32,7 @@ public class TSDBJNIConnector {
// Connection pointer used in C
private
long
taos
=
TSDBConstants
.
JNI_NULL_POINTER
;
// result set status in current connection
private
boolean
isResultsetClosed
=
true
;
private
boolean
isResultsetClosed
;
private
int
affectedRows
=
-
1
;
static
{
...
...
@@ -135,6 +135,7 @@ public class TSDBJNIConnector {
// Try retrieving result set for the executed SQL using the current connection pointer.
pSql
=
this
.
getResultSetImp
(
this
.
taos
,
pSql
);
// if pSql == 0L that means resultset is closed
isResultsetClosed
=
(
pSql
==
TSDBConstants
.
JNI_NULL_POINTER
);
return
pSql
;
...
...
@@ -172,16 +173,7 @@ public class TSDBJNIConnector {
* Free resultset operation from C to release resultset pointer by JNI
*/
public
int
freeResultSet
(
long
pSql
)
{
int
res
=
TSDBConstants
.
JNI_SUCCESS
;
// if (result != taosResultSetPointer && taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
// throw new RuntimeException("Invalid result set pointer");
// }
// if (taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
res
=
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
// taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
// }
int
res
=
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
isResultsetClosed
=
true
;
return
res
;
}
...
...
@@ -199,7 +191,6 @@ public class TSDBJNIConnector {
// }
// return resCode;
// }
private
native
int
freeResultSetImp
(
long
connection
,
long
result
);
/**
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
浏览文件 @
5131e7b1
...
...
@@ -109,6 +109,8 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
public
void
close
()
throws
SQLException
{
if
(
isClosed
)
return
;
if
(
this
.
statement
==
null
)
return
;
if
(
this
.
jniConnector
!=
null
)
{
int
code
=
this
.
jniConnector
.
freeResultSet
(
this
.
resultSetPointer
);
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
...
...
@@ -461,12 +463,13 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
}
public
boolean
isClosed
()
throws
SQLException
{
if
(
isClosed
)
return
true
;
if
(
jniConnector
!=
null
)
{
isClosed
=
jniConnector
.
isResultsetClosed
();
}
return
isClosed
;
// if (isClosed)
// return true;
// if (jniConnector != null) {
// isClosed = jniConnector.isResultsetClosed();
// }
// return isClosed;
}
public
String
getNString
(
int
columnIndex
)
throws
SQLException
{
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
浏览文件 @
5131e7b1
package
com.taosdata.jdbc
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -19,6 +20,7 @@ public class SubscribeTest {
String
tName
=
"t0"
;
String
host
=
"127.0.0.1"
;
String
topic
=
"test"
;
private
long
ts
;
@Test
public
void
subscribe
()
{
...
...
@@ -27,26 +29,40 @@ public class SubscribeTest {
TSDBConnection
conn
=
connection
.
unwrap
(
TSDBConnection
.
class
);
TSDBSubscribe
subscribe
=
conn
.
subscribe
(
topic
,
rawSql
,
false
);
int
a
=
0
;
while
(
true
)
{
TimeUnit
.
MILLISECONDS
.
sleep
(
1000
);
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
TimeUnit
.
SECONDS
.
sleep
(
1
);
TSDBResultSet
resSet
=
subscribe
.
consume
();
int
rowCnt
=
0
;
while
(
resSet
.
next
())
{
for
(
int
i
=
1
;
i
<=
resSet
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
printf
(
i
+
": "
+
resSet
.
getString
(
i
)
+
"\t"
);
if
(
rowCnt
==
0
)
{
long
cur_ts
=
resSet
.
getTimestamp
(
1
).
getTime
();
int
k
=
resSet
.
getInt
(
2
);
int
v
=
resSet
.
getInt
(
3
);
Assert
.
assertEquals
(
ts
,
cur_ts
);
Assert
.
assertEquals
(
100
,
k
);
Assert
.
assertEquals
(
1
,
v
);
}
System
.
out
.
println
(
"\n======"
+
a
+
"=========="
);
}
a
++;
if
(
a
>=
2
)
{
break
;
if
(
rowCnt
==
1
)
{
long
cur_ts
=
resSet
.
getTimestamp
(
1
).
getTime
();
int
k
=
resSet
.
getInt
(
2
);
int
v
=
resSet
.
getInt
(
3
);
Assert
.
assertEquals
(
ts
+
1
,
cur_ts
);
Assert
.
assertEquals
(
101
,
k
);
Assert
.
assertEquals
(
2
,
v
);
}
rowCnt
++;
}
if
(
j
==
0
)
Assert
.
assertEquals
(
2
,
rowCnt
);
resSet
.
close
();
}
subscribe
.
close
(
true
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
catch
(
SQLException
|
InterruptedException
throwables
)
{
throwables
.
printStackTrace
();
}
}
...
...
@@ -62,7 +78,7 @@ public class SubscribeTest {
statement
.
execute
(
"drop database if exists "
+
dbName
);
statement
.
execute
(
"create database if not exists "
+
dbName
);
statement
.
execute
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
" (ts timestamp, k int, v int)"
);
long
ts
=
System
.
currentTimeMillis
();
ts
=
System
.
currentTimeMillis
();
statement
.
executeUpdate
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", 100, 1)"
);
statement
.
executeUpdate
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
(
ts
+
1
)
+
", 101, 2)"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录