Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
2bb969a9
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2bb969a9
编写于
6月 09, 2020
作者:
S
Shuaiqiang Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests:add import
上级
db6f4514
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
18 deletion
+31
-18
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBAsyncSubscribeTest.java
...c/test/java/com/taosdata/jdbc/TSDBAsyncSubscribeTest.java
+3
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBImportTest.java
.../jdbc/src/test/java/com/taosdata/jdbc/TSDBImportTest.java
+20
-10
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBSubscribeTest.java
...bc/src/test/java/com/taosdata/jdbc/TSDBSubscribeTest.java
+3
-3
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
2bb969a9
...
...
@@ -51,13 +51,17 @@ public class TSDBStatement implements Statement {
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
this
.
connecter
.
executeQuery
(
sql
);
System
.
out
.
println
(
sql
);
long
res
=
this
.
connecter
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connecter
.
getResultSet
();
if
(
resultSetPointer
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
this
.
connecter
.
freeResultSet
(
res
);
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
else
if
(
resultSetPointer
==
TSDBConstants
.
JNI_NULL_POINTER
)
{
// create/insert/update/del/alter
this
.
connecter
.
freeResultSet
(
res
);
return
null
;
}
else
{
return
new
TSDBResultSet
(
this
.
connecter
,
resultSetPointer
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBAsyncSubscribeTest.java
浏览文件 @
2bb969a9
...
...
@@ -21,7 +21,7 @@ public class TSDBAsyncSubscribeTest {
String
topic
=
"test"
;
long
subscribId
=
0
;
//
@Before
@Before
public
void
createDatabase
()
throws
SQLException
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
...
...
@@ -43,7 +43,7 @@ public class TSDBAsyncSubscribeTest {
}
}
//
@Test
@Test
public
void
subscribe
()
throws
Exception
{
TSDBSubscribe
subscribe
=
null
;
try
{
...
...
@@ -70,7 +70,6 @@ public class TSDBAsyncSubscribeTest {
@Override
public
void
invoke
(
TSDBResultSet
resultSet
)
{
System
.
out
.
println
(
"resultSet"
);
try
{
while
(
null
!=
resultSet
&&
resultSet
.
next
())
{
System
.
out
.
print
(
"callback_"
+
name
+
": "
);
...
...
@@ -87,7 +86,7 @@ public class TSDBAsyncSubscribeTest {
}
}
//
@After
@After
public
void
close
()
throws
Exception
{
statement
.
executeQuery
(
"drop database test"
);
statement
.
close
();
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBImportTest.java
浏览文件 @
2bb969a9
...
...
@@ -4,10 +4,7 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.*
;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -40,20 +37,33 @@ public class TSDBImportTest {
@Test
public
void
insertInto
()
throws
Exception
{
long
ts
=
System
.
currentTimeMillis
()
;
long
ts
=
1496732686000
l
;
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
ts
+
=
i
;
ts
+
+
;
int
row
=
statement
.
executeUpdate
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")"
);
System
.
out
.
println
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")
"
+
"
\t"
+
row
);
System
.
out
.
println
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")\t"
+
row
);
assertEquals
(
1
,
row
);
}
}
@Test
public
void
selectData
()
throws
Exception
{
String
sql
=
"select * from test.t0"
;
ResultSet
resSet
=
statement
.
executeQuery
(
sql
);
while
(
resSet
.
next
())
{
for
(
int
i
=
1
;
i
<=
resSet
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
printf
(
i
+
": "
+
resSet
.
getString
(
i
)
+
"\t"
);
}
}
resSet
.
close
();
}
@Test
public
void
importInto
()
throws
Exception
{
// 避免时间重复
long
ts
=
System
.
currentTimeMillis
()
+
1000
;
long
ts
=
1496732686000
l
;
StringBuilder
sqlBuilder
=
new
StringBuilder
(
"insert into "
).
append
(
dbName
).
append
(
"."
).
append
(
tName
).
append
(
" values "
);
...
...
@@ -68,9 +78,9 @@ public class TSDBImportTest {
assertEquals
(
10
,
rows
);
}
@After
//
@After
public
void
close
()
throws
Exception
{
statement
.
execute
Query
(
"drop database "
+
dbName
);
statement
.
execute
Update
(
"drop database "
+
dbName
);
statement
.
close
();
connection
.
close
();
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBSubscribeTest.java
浏览文件 @
2bb969a9
...
...
@@ -20,7 +20,7 @@ public class TSDBSubscribeTest {
String
host
=
"localhost"
;
String
topic
=
"test"
;
//
@Before
@Before
public
void
createDatabase
()
throws
SQLException
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
...
...
@@ -42,7 +42,7 @@ public class TSDBSubscribeTest {
}
}
//
@Test
@Test
public
void
subscribe
()
throws
Exception
{
TSDBSubscribe
subscribe
=
null
;
long
subscribId
=
0
;
...
...
@@ -81,7 +81,7 @@ public class TSDBSubscribeTest {
}
}
//
@After
@After
public
void
close
()
throws
Exception
{
statement
.
executeQuery
(
"drop database "
+
dbName
);
statement
.
close
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录