Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
cfe44225
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看板
提交
cfe44225
编写于
1月 11, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2695]<test>: change jdbc unit test cases
上级
7dbfd400
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
22 addition
and
18 deletion
+22
-18
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java
.../main/java/com/taosdata/taosdemo/TaosDemoApplication.java
+3
-5
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java
...in/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java
+4
-4
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java
...in/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java
+5
-5
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java
.../java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java
+2
-2
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java
.../main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java
+7
-1
tests/examples/JDBC/taosdemo/src/main/resources/log4j.properties
...xamples/JDBC/taosdemo/src/main/resources/log4j.properties
+1
-1
未找到文件。
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java
浏览文件 @
cfe44225
...
...
@@ -19,14 +19,13 @@ import java.util.Map;
public
class
TaosDemoApplication
{
private
static
Logger
logger
=
Logger
.
getLogger
(
TaosDemoApplication
.
class
);
private
static
final
Logger
logger
=
Logger
.
getLogger
(
TaosDemoApplication
.
class
);
public
static
void
main
(
String
[]
args
)
throws
IOException
{
// 读配置参数
JdbcTaosdemoConfig
config
=
new
JdbcTaosdemoConfig
(
args
);
boolean
isHelp
=
Arrays
.
asList
(
args
).
contains
(
"--help"
);
if
(
isHelp
||
config
.
host
==
null
||
config
.
host
.
isEmpty
())
{
// if (isHelp) {
JdbcTaosdemoConfig
.
printHelp
();
System
.
exit
(
0
);
}
...
...
@@ -75,7 +74,7 @@ public class TaosDemoApplication {
}
}
end
=
System
.
currentTimeMillis
();
logger
.
error
(
">>> create table time cost : "
+
(
end
-
start
)
+
" ms."
);
logger
.
info
(
">>> create table time cost : "
+
(
end
-
start
)
+
" ms."
);
/**********************************************************************************/
// 插入
long
tableSize
=
config
.
numOfTables
;
...
...
@@ -90,7 +89,7 @@ public class TaosDemoApplication {
// multi threads to insert
int
affectedRows
=
subTableService
.
insertMultiThreads
(
superTableMeta
,
threadSize
,
tableSize
,
startTime
,
gap
,
config
);
end
=
System
.
currentTimeMillis
();
logger
.
error
(
"insert "
+
affectedRows
+
" rows, time cost: "
+
(
end
-
start
)
+
" ms"
);
logger
.
info
(
"insert "
+
affectedRows
+
" rows, time cost: "
+
(
end
-
start
)
+
" ms"
);
/**********************************************************************************/
// 删除表
if
(
config
.
dropTable
)
{
...
...
@@ -108,5 +107,4 @@ public class TaosDemoApplication {
return
startTime
;
}
}
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java
浏览文件 @
cfe44225
...
...
@@ -21,27 +21,27 @@ public class DatabaseMapperImpl implements DatabaseMapper {
public
void
createDatabase
(
String
dbname
)
{
String
sql
=
"create database if not exists "
+
dbname
;
jdbcTemplate
.
execute
(
sql
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
}
@Override
public
void
dropDatabase
(
String
dbname
)
{
String
sql
=
"drop database if exists "
+
dbname
;
jdbcTemplate
.
update
(
sql
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
}
@Override
public
void
createDatabaseWithParameters
(
Map
<
String
,
String
>
map
)
{
String
sql
=
SqlSpeller
.
createDatabase
(
map
);
jdbcTemplate
.
execute
(
sql
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
}
@Override
public
void
useDatabase
(
String
dbname
)
{
String
sql
=
"use "
+
dbname
;
jdbcTemplate
.
execute
(
sql
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
}
}
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java
浏览文件 @
cfe44225
...
...
@@ -21,14 +21,14 @@ public class SubTableMapperImpl implements SubTableMapper {
@Override
public
void
createUsingSuperTable
(
SubTableMeta
subTableMeta
)
{
String
sql
=
SqlSpeller
.
createTableUsingSuperTable
(
subTableMeta
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
jdbcTemplate
.
execute
(
sql
);
}
@Override
public
int
insertOneTableMultiValues
(
SubTableValue
subTableValue
)
{
String
sql
=
SqlSpeller
.
insertOneTableMultiValues
(
subTableValue
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
int
affectRows
=
0
;
try
{
...
...
@@ -42,7 +42,7 @@ public class SubTableMapperImpl implements SubTableMapper {
@Override
public
int
insertOneTableMultiValuesUsingSuperTable
(
SubTableValue
subTableValue
)
{
String
sql
=
SqlSpeller
.
insertOneTableMultiValuesUsingSuperTable
(
subTableValue
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
int
affectRows
=
0
;
try
{
...
...
@@ -56,7 +56,7 @@ public class SubTableMapperImpl implements SubTableMapper {
@Override
public
int
insertMultiTableMultiValues
(
List
<
SubTableValue
>
tables
)
{
String
sql
=
SqlSpeller
.
insertMultiSubTableMultiValues
(
tables
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
int
affectRows
=
0
;
try
{
affectRows
=
jdbcTemplate
.
update
(
sql
);
...
...
@@ -69,7 +69,7 @@ public class SubTableMapperImpl implements SubTableMapper {
@Override
public
int
insertMultiTableMultiValuesUsingSuperTable
(
List
<
SubTableValue
>
tables
)
{
String
sql
=
SqlSpeller
.
insertMultiTableMultiValuesUsingSuperTable
(
tables
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
int
affectRows
=
0
;
try
{
affectRows
=
jdbcTemplate
.
update
(
sql
);
...
...
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java
浏览文件 @
cfe44225
...
...
@@ -18,14 +18,14 @@ public class SuperTableMapperImpl implements SuperTableMapper {
@Override
public
void
createSuperTable
(
SuperTableMeta
tableMetadata
)
{
String
sql
=
SqlSpeller
.
createSuperTable
(
tableMetadata
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
jdbcTemplate
.
execute
(
sql
);
}
@Override
public
void
dropSuperTable
(
String
database
,
String
name
)
{
String
sql
=
"drop table if exists "
+
database
+
"."
+
name
;
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
jdbcTemplate
.
execute
(
sql
);
}
}
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java
浏览文件 @
cfe44225
package
com.taosdata.taosdemo.dao
;
import
com.taosdata.taosdemo.dao.TableMapper
;
import
com.taosdata.taosdemo.domain.TableMeta
;
import
com.taosdata.taosdemo.domain.TableValue
;
import
com.taosdata.taosdemo.utils.SqlSpeller
;
import
org.apache.log4j.Logger
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
java.util.List
;
public
class
TableMapperImpl
implements
TableMapper
{
private
static
final
Logger
logger
=
Logger
.
getLogger
(
TableMapperImpl
.
class
);
private
JdbcTemplate
template
;
@Override
public
void
create
(
TableMeta
tableMeta
)
{
String
sql
=
SqlSpeller
.
createTable
(
tableMeta
);
logger
.
debug
(
"SQL >>> "
+
sql
);
template
.
execute
(
sql
);
}
@Override
public
int
insertOneTableMultiValues
(
TableValue
values
)
{
String
sql
=
SqlSpeller
.
insertOneTableMultiValues
(
values
);
logger
.
debug
(
"SQL >>> "
+
sql
);
return
template
.
update
(
sql
);
}
@Override
public
int
insertOneTableMultiValuesWithColumns
(
TableValue
values
)
{
String
sql
=
SqlSpeller
.
insertOneTableMultiValuesWithColumns
(
values
);
logger
.
debug
(
"SQL >>> "
+
sql
);
return
template
.
update
(
sql
);
}
@Override
public
int
insertMultiTableMultiValues
(
List
<
TableValue
>
tables
)
{
String
sql
=
SqlSpeller
.
insertMultiTableMultiValues
(
tables
);
logger
.
debug
(
"SQL >>> "
+
sql
);
return
template
.
update
(
sql
);
}
@Override
public
int
insertMultiTableMultiValuesWithColumns
(
List
<
TableValue
>
tables
)
{
String
sql
=
SqlSpeller
.
insertMultiTableMultiValuesWithColumns
(
tables
);
logger
.
debug
(
"SQL >>> "
+
sql
);
return
template
.
update
(
sql
);
}
}
tests/examples/JDBC/taosdemo/src/main/resources/log4j.properties
浏览文件 @
cfe44225
### 设置###
log4j.rootLogger
=
error
,stdout
log4j.rootLogger
=
info
,stdout
### 输出信息到控制抬 ###
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录