Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
a5f02a89
T
TDengine
项目概览
小楼昨夜-听风雨
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a5f02a89
编写于
2月 03, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
ffcc0dec
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
125 addition
and
21 deletion
+125
-21
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+2
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java
...bc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java
+123
-19
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
a5f02a89
...
...
@@ -132,7 +132,7 @@ public class TSDBStatement extends AbstractStatement {
public
void
clearBatch
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
!=
null
)
batchedArgs
.
clear
();
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java
浏览文件 @
a5f02a89
...
...
@@ -34,11 +34,14 @@ public class TSDBStatementTest {
@Test
public
void
executeUpdate
()
{
String
dbName
=
"test_"
+
UUID
.
randomUUID
();
dbName
=
dbName
.
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
int
affectRows
=
stmt
.
executeUpdate
(
"create database "
+
dbName
);
Assert
.
assertEquals
(
0
,
affectRows
);
affectRows
=
stmt
.
executeUpdate
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
Assert
.
assertEquals
(
0
,
affectRows
);
affectRows
=
stmt
.
executeUpdate
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
Assert
.
assertEquals
(
1
,
affectRows
);
affectRows
=
stmt
.
executeUpdate
(
"drop database "
+
dbName
);
Assert
.
assertEquals
(
0
,
affectRows
);
}
catch
(
SQLException
e
)
{
...
...
@@ -52,51 +55,152 @@ public class TSDBStatementTest {
@Test
public
void
execute
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
boolean
isSelect
=
stmt
.
execute
(
"create database "
+
dbName
);
Assert
.
assertEquals
(
false
,
isSelect
);
int
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
1
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"select * from "
+
dbName
+
".weather"
);
Assert
.
assertEquals
(
true
,
isSelect
);
isSelect
=
stmt
.
execute
(
"drop database "
+
dbName
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
getResultSet
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
boolean
isSelect
=
stmt
.
execute
(
"create database "
+
dbName
);
Assert
.
assertEquals
(
false
,
isSelect
);
int
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
1
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"select * from "
+
dbName
+
".weather"
);
Assert
.
assertEquals
(
true
,
isSelect
);
ResultSet
rs
=
stmt
.
getResultSet
();
Assert
.
assertNotNull
(
rs
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
Assert
.
assertEquals
(
3
,
meta
.
getColumnCount
());
int
count
=
0
;
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
": "
+
rs
.
getString
(
i
)
+
"\t"
);
}
@Test
public
void
getUpdateCount
()
{
System
.
out
.
println
();
count
++;
}
Assert
.
assertEquals
(
1
,
count
);
@Test
public
void
getResultSetConcurrency
()
{
isSelect
=
stmt
.
execute
(
"drop database "
+
dbName
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
getResultSetType
()
{
public
void
getUpdateCount
()
{
execute
();
}
@Test
public
void
addBatch
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
stmt
.
addBatch
(
"create database "
+
dbName
);
stmt
.
addBatch
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
stmt
.
addBatch
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
stmt
.
addBatch
(
"select * from "
+
dbName
+
".weather"
);
stmt
.
addBatch
(
"drop database "
+
dbName
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
clearBatch
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
stmt
.
clearBatch
();
stmt
.
addBatch
(
"create database "
+
dbName
);
stmt
.
addBatch
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
stmt
.
addBatch
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
stmt
.
addBatch
(
"select * from "
+
dbName
+
".weather"
);
stmt
.
addBatch
(
"drop database "
+
dbName
);
stmt
.
clearBatch
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
executeBatch
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
stmt
.
addBatch
(
"create database "
+
dbName
);
stmt
.
addBatch
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
stmt
.
addBatch
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
stmt
.
addBatch
(
"select * from "
+
dbName
+
".weather"
);
stmt
.
addBatch
(
"drop database "
+
dbName
);
int
[]
results
=
stmt
.
executeBatch
();
Assert
.
assertEquals
(
0
,
results
[
0
]);
Assert
.
assertEquals
(
0
,
results
[
1
]);
Assert
.
assertEquals
(
1
,
results
[
2
]);
Assert
.
assertEquals
(
Statement
.
SUCCESS_NO_INFO
,
results
[
3
]);
Assert
.
assertEquals
(
0
,
results
[
4
]);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
@Test
public
void
getConnection
()
{
}
@Test
public
void
getMoreResults
()
{
public
void
getConnection
()
{
try
{
Connection
connection
=
stmt
.
getConnection
();
Assert
.
assertNotNull
(
connection
);
Assert
.
assertTrue
(
this
.
conn
==
connection
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
@Test
public
void
getResultSetHoldability
()
{
}
@Test
public
void
isClosed
()
{
try
{
Assert
.
assertEquals
(
false
,
stmt
.
isClosed
());
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@BeforeClass
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录