Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c547b894
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看板
提交
c547b894
编写于
8月 31, 2021
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6468]<test>: add test case for jdbc stmt
上级
606455a9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
124 addition
and
0 deletion
+124
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java
...est/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java
+124
-0
未找到文件。
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java
浏览文件 @
c547b894
...
...
@@ -586,6 +586,130 @@ public class TSDBPreparedStatementTest {
Assert
.
assertEquals
(
numOfRows
,
rows
);
}
@Test
public
void
bindDataQueryTest
()
throws
SQLException
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop table if exists weather_test"
);
stmt
.
execute
(
"create table weather_test(ts timestamp, f1 nchar(10), f2 binary(10)) tags (t1 int, t2 binary(10))"
);
int
numOfRows
=
1
;
TSDBPreparedStatement
s
=
(
TSDBPreparedStatement
)
conn
.
prepareStatement
(
"insert into ? using weather_test tags(?,?) (ts, f2) values(?, ?)"
);
s
.
setTableName
(
"w2"
);
s
.
setTagInt
(
0
,
1
);
s
.
setTagString
(
1
,
"test"
);
ArrayList
<
Long
>
ts
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
numOfRows
;
i
++)
{
ts
.
add
(
System
.
currentTimeMillis
()
+
i
);
}
s
.
setTimestamp
(
0
,
ts
);
ArrayList
<
String
>
s2
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
numOfRows
;
i
++)
{
s2
.
add
(
"test"
+
i
%
4
);
}
s
.
setString
(
1
,
s2
,
10
);
s
.
columnDataAddBatch
();
s
.
columnDataExecuteBatch
();
s
.
columnDataCloseBatch
();
String
sql
=
"select * from weather_test where t1 >= ? and t1 <= ?"
;
TSDBPreparedStatement
s1
=
(
TSDBPreparedStatement
)
conn
.
prepareStatement
(
sql
);
s1
.
setInt
(
1
,
0
);
s1
.
setInt
(
2
,
10
);
ResultSet
rs
=
s1
.
executeQuery
();
int
rows
=
0
;
while
(
rs
.
next
())
{
rows
++;
}
Assert
.
assertEquals
(
numOfRows
,
rows
);
}
@Test
public
void
setTagNullTest
()
throws
SQLException
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop table if exists weather_test"
);
stmt
.
execute
(
"create table weather_test(ts timestamp, c1 int) tags (t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 bool, t8 binary(10), t9 nchar(10))"
);
int
numOfRows
=
1
;
TSDBPreparedStatement
s
=
(
TSDBPreparedStatement
)
conn
.
prepareStatement
(
"insert into ? using weather_test tags(?,?,?,?,?,?,?,?,?) values(?, ?)"
);
s
.
setTableName
(
"w3"
);
s
.
setTagNull
(
0
,
TSDBConstants
.
TSDB_DATA_TYPE_TINYINT
);
s
.
setTagNull
(
1
,
TSDBConstants
.
TSDB_DATA_TYPE_SMALLINT
);
s
.
setTagNull
(
2
,
TSDBConstants
.
TSDB_DATA_TYPE_INT
);
s
.
setTagNull
(
3
,
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
);
s
.
setTagNull
(
4
,
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
);
s
.
setTagNull
(
5
,
TSDBConstants
.
TSDB_DATA_TYPE_DOUBLE
);
s
.
setTagNull
(
6
,
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
);
s
.
setTagNull
(
7
,
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
);
s
.
setTagNull
(
8
,
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
);
ArrayList
<
Long
>
ts
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
numOfRows
;
i
++)
{
ts
.
add
(
System
.
currentTimeMillis
()
+
i
);
}
s
.
setTimestamp
(
0
,
ts
);
ArrayList
<
Integer
>
s2
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
numOfRows
;
i
++)
{
s2
.
add
(
i
);
}
s
.
setInt
(
1
,
s2
);
s
.
columnDataAddBatch
();
s
.
columnDataExecuteBatch
();
s
.
columnDataCloseBatch
();
}
private
String
stringGenerator
(
int
length
)
{
String
source
=
"abcdefghijklmnopqrstuvwxyz"
;
StringBuilder
sb
=
new
StringBuilder
();
Random
rand
=
new
Random
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
sb
.
append
(
source
.
charAt
(
rand
.
nextInt
(
26
)));
}
return
sb
.
toString
();
}
@Test
(
expected
=
SQLException
.
class
)
public
void
setMaxTableNameTest
()
throws
SQLException
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop table if exists weather_test"
);
stmt
.
execute
(
"create table weather_test(ts timestamp, c1 int) tags (t1 int)"
);
TSDBPreparedStatement
s
=
(
TSDBPreparedStatement
)
conn
.
prepareStatement
(
"insert into ? using weather_test tags(?) values(?, ?)"
);
String
tbname
=
stringGenerator
(
193
);
s
.
setTableName
(
tbname
);
s
.
setTagInt
(
0
,
1
);
int
numOfRows
=
1
;
ArrayList
<
Long
>
ts
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
numOfRows
;
i
++)
{
ts
.
add
(
System
.
currentTimeMillis
()
+
i
);
}
s
.
setTimestamp
(
0
,
ts
);
ArrayList
<
Integer
>
s2
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
numOfRows
;
i
++)
{
s2
.
add
(
i
);
}
s
.
setInt
(
1
,
s2
);
s
.
columnDataAddBatch
();
s
.
columnDataExecuteBatch
();
s
.
columnDataCloseBatch
();
}
@Test
(
expected
=
SQLException
.
class
)
public
void
createTwoSameDbTest
()
throws
SQLException
{
// when
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录