Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
~笨蛋陪你哭
TDengine
提交
cfe44225
T
TDengine
项目概览
~笨蛋陪你哭
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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,发现更多精彩内容 >>
提交
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;
...
@@ -19,14 +19,13 @@ import java.util.Map;
public
class
TaosDemoApplication
{
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
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
// 读配置参数
// 读配置参数
JdbcTaosdemoConfig
config
=
new
JdbcTaosdemoConfig
(
args
);
JdbcTaosdemoConfig
config
=
new
JdbcTaosdemoConfig
(
args
);
boolean
isHelp
=
Arrays
.
asList
(
args
).
contains
(
"--help"
);
boolean
isHelp
=
Arrays
.
asList
(
args
).
contains
(
"--help"
);
if
(
isHelp
||
config
.
host
==
null
||
config
.
host
.
isEmpty
())
{
if
(
isHelp
||
config
.
host
==
null
||
config
.
host
.
isEmpty
())
{
// if (isHelp) {
JdbcTaosdemoConfig
.
printHelp
();
JdbcTaosdemoConfig
.
printHelp
();
System
.
exit
(
0
);
System
.
exit
(
0
);
}
}
...
@@ -75,7 +74,7 @@ public class TaosDemoApplication {
...
@@ -75,7 +74,7 @@ public class TaosDemoApplication {
}
}
}
}
end
=
System
.
currentTimeMillis
();
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
;
long
tableSize
=
config
.
numOfTables
;
...
@@ -90,7 +89,7 @@ public class TaosDemoApplication {
...
@@ -90,7 +89,7 @@ public class TaosDemoApplication {
// multi threads to insert
// multi threads to insert
int
affectedRows
=
subTableService
.
insertMultiThreads
(
superTableMeta
,
threadSize
,
tableSize
,
startTime
,
gap
,
config
);
int
affectedRows
=
subTableService
.
insertMultiThreads
(
superTableMeta
,
threadSize
,
tableSize
,
startTime
,
gap
,
config
);
end
=
System
.
currentTimeMillis
();
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
)
{
if
(
config
.
dropTable
)
{
...
@@ -108,5 +107,4 @@ public class TaosDemoApplication {
...
@@ -108,5 +107,4 @@ public class TaosDemoApplication {
return
startTime
;
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 {
...
@@ -21,27 +21,27 @@ public class DatabaseMapperImpl implements DatabaseMapper {
public
void
createDatabase
(
String
dbname
)
{
public
void
createDatabase
(
String
dbname
)
{
String
sql
=
"create database if not exists "
+
dbname
;
String
sql
=
"create database if not exists "
+
dbname
;
jdbcTemplate
.
execute
(
sql
);
jdbcTemplate
.
execute
(
sql
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
}
}
@Override
@Override
public
void
dropDatabase
(
String
dbname
)
{
public
void
dropDatabase
(
String
dbname
)
{
String
sql
=
"drop database if exists "
+
dbname
;
String
sql
=
"drop database if exists "
+
dbname
;
jdbcTemplate
.
update
(
sql
);
jdbcTemplate
.
update
(
sql
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
}
}
@Override
@Override
public
void
createDatabaseWithParameters
(
Map
<
String
,
String
>
map
)
{
public
void
createDatabaseWithParameters
(
Map
<
String
,
String
>
map
)
{
String
sql
=
SqlSpeller
.
createDatabase
(
map
);
String
sql
=
SqlSpeller
.
createDatabase
(
map
);
jdbcTemplate
.
execute
(
sql
);
jdbcTemplate
.
execute
(
sql
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
}
}
@Override
@Override
public
void
useDatabase
(
String
dbname
)
{
public
void
useDatabase
(
String
dbname
)
{
String
sql
=
"use "
+
dbname
;
String
sql
=
"use "
+
dbname
;
jdbcTemplate
.
execute
(
sql
);
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 {
...
@@ -21,14 +21,14 @@ public class SubTableMapperImpl implements SubTableMapper {
@Override
@Override
public
void
createUsingSuperTable
(
SubTableMeta
subTableMeta
)
{
public
void
createUsingSuperTable
(
SubTableMeta
subTableMeta
)
{
String
sql
=
SqlSpeller
.
createTableUsingSuperTable
(
subTableMeta
);
String
sql
=
SqlSpeller
.
createTableUsingSuperTable
(
subTableMeta
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
jdbcTemplate
.
execute
(
sql
);
jdbcTemplate
.
execute
(
sql
);
}
}
@Override
@Override
public
int
insertOneTableMultiValues
(
SubTableValue
subTableValue
)
{
public
int
insertOneTableMultiValues
(
SubTableValue
subTableValue
)
{
String
sql
=
SqlSpeller
.
insertOneTableMultiValues
(
subTableValue
);
String
sql
=
SqlSpeller
.
insertOneTableMultiValues
(
subTableValue
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
int
affectRows
=
0
;
int
affectRows
=
0
;
try
{
try
{
...
@@ -42,7 +42,7 @@ public class SubTableMapperImpl implements SubTableMapper {
...
@@ -42,7 +42,7 @@ public class SubTableMapperImpl implements SubTableMapper {
@Override
@Override
public
int
insertOneTableMultiValuesUsingSuperTable
(
SubTableValue
subTableValue
)
{
public
int
insertOneTableMultiValuesUsingSuperTable
(
SubTableValue
subTableValue
)
{
String
sql
=
SqlSpeller
.
insertOneTableMultiValuesUsingSuperTable
(
subTableValue
);
String
sql
=
SqlSpeller
.
insertOneTableMultiValuesUsingSuperTable
(
subTableValue
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
int
affectRows
=
0
;
int
affectRows
=
0
;
try
{
try
{
...
@@ -56,7 +56,7 @@ public class SubTableMapperImpl implements SubTableMapper {
...
@@ -56,7 +56,7 @@ public class SubTableMapperImpl implements SubTableMapper {
@Override
@Override
public
int
insertMultiTableMultiValues
(
List
<
SubTableValue
>
tables
)
{
public
int
insertMultiTableMultiValues
(
List
<
SubTableValue
>
tables
)
{
String
sql
=
SqlSpeller
.
insertMultiSubTableMultiValues
(
tables
);
String
sql
=
SqlSpeller
.
insertMultiSubTableMultiValues
(
tables
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
int
affectRows
=
0
;
int
affectRows
=
0
;
try
{
try
{
affectRows
=
jdbcTemplate
.
update
(
sql
);
affectRows
=
jdbcTemplate
.
update
(
sql
);
...
@@ -69,7 +69,7 @@ public class SubTableMapperImpl implements SubTableMapper {
...
@@ -69,7 +69,7 @@ public class SubTableMapperImpl implements SubTableMapper {
@Override
@Override
public
int
insertMultiTableMultiValuesUsingSuperTable
(
List
<
SubTableValue
>
tables
)
{
public
int
insertMultiTableMultiValuesUsingSuperTable
(
List
<
SubTableValue
>
tables
)
{
String
sql
=
SqlSpeller
.
insertMultiTableMultiValuesUsingSuperTable
(
tables
);
String
sql
=
SqlSpeller
.
insertMultiTableMultiValuesUsingSuperTable
(
tables
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
int
affectRows
=
0
;
int
affectRows
=
0
;
try
{
try
{
affectRows
=
jdbcTemplate
.
update
(
sql
);
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 {
...
@@ -18,14 +18,14 @@ public class SuperTableMapperImpl implements SuperTableMapper {
@Override
@Override
public
void
createSuperTable
(
SuperTableMeta
tableMetadata
)
{
public
void
createSuperTable
(
SuperTableMeta
tableMetadata
)
{
String
sql
=
SqlSpeller
.
createSuperTable
(
tableMetadata
);
String
sql
=
SqlSpeller
.
createSuperTable
(
tableMetadata
);
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
jdbcTemplate
.
execute
(
sql
);
jdbcTemplate
.
execute
(
sql
);
}
}
@Override
@Override
public
void
dropSuperTable
(
String
database
,
String
name
)
{
public
void
dropSuperTable
(
String
database
,
String
name
)
{
String
sql
=
"drop table if exists "
+
database
+
"."
+
name
;
String
sql
=
"drop table if exists "
+
database
+
"."
+
name
;
logger
.
info
(
"SQL >>> "
+
sql
);
logger
.
debug
(
"SQL >>> "
+
sql
);
jdbcTemplate
.
execute
(
sql
);
jdbcTemplate
.
execute
(
sql
);
}
}
}
}
tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java
浏览文件 @
cfe44225
package
com.taosdata.taosdemo.dao
;
package
com.taosdata.taosdemo.dao
;
import
com.taosdata.taosdemo.dao.TableMapper
;
import
com.taosdata.taosdemo.domain.TableMeta
;
import
com.taosdata.taosdemo.domain.TableMeta
;
import
com.taosdata.taosdemo.domain.TableValue
;
import
com.taosdata.taosdemo.domain.TableValue
;
import
com.taosdata.taosdemo.utils.SqlSpeller
;
import
com.taosdata.taosdemo.utils.SqlSpeller
;
import
org.apache.log4j.Logger
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
java.util.List
;
import
java.util.List
;
public
class
TableMapperImpl
implements
TableMapper
{
public
class
TableMapperImpl
implements
TableMapper
{
private
static
final
Logger
logger
=
Logger
.
getLogger
(
TableMapperImpl
.
class
);
private
JdbcTemplate
template
;
private
JdbcTemplate
template
;
@Override
@Override
public
void
create
(
TableMeta
tableMeta
)
{
public
void
create
(
TableMeta
tableMeta
)
{
String
sql
=
SqlSpeller
.
createTable
(
tableMeta
);
String
sql
=
SqlSpeller
.
createTable
(
tableMeta
);
logger
.
debug
(
"SQL >>> "
+
sql
);
template
.
execute
(
sql
);
template
.
execute
(
sql
);
}
}
@Override
@Override
public
int
insertOneTableMultiValues
(
TableValue
values
)
{
public
int
insertOneTableMultiValues
(
TableValue
values
)
{
String
sql
=
SqlSpeller
.
insertOneTableMultiValues
(
values
);
String
sql
=
SqlSpeller
.
insertOneTableMultiValues
(
values
);
logger
.
debug
(
"SQL >>> "
+
sql
);
return
template
.
update
(
sql
);
return
template
.
update
(
sql
);
}
}
@Override
@Override
public
int
insertOneTableMultiValuesWithColumns
(
TableValue
values
)
{
public
int
insertOneTableMultiValuesWithColumns
(
TableValue
values
)
{
String
sql
=
SqlSpeller
.
insertOneTableMultiValuesWithColumns
(
values
);
String
sql
=
SqlSpeller
.
insertOneTableMultiValuesWithColumns
(
values
);
logger
.
debug
(
"SQL >>> "
+
sql
);
return
template
.
update
(
sql
);
return
template
.
update
(
sql
);
}
}
@Override
@Override
public
int
insertMultiTableMultiValues
(
List
<
TableValue
>
tables
)
{
public
int
insertMultiTableMultiValues
(
List
<
TableValue
>
tables
)
{
String
sql
=
SqlSpeller
.
insertMultiTableMultiValues
(
tables
);
String
sql
=
SqlSpeller
.
insertMultiTableMultiValues
(
tables
);
logger
.
debug
(
"SQL >>> "
+
sql
);
return
template
.
update
(
sql
);
return
template
.
update
(
sql
);
}
}
@Override
@Override
public
int
insertMultiTableMultiValuesWithColumns
(
List
<
TableValue
>
tables
)
{
public
int
insertMultiTableMultiValuesWithColumns
(
List
<
TableValue
>
tables
)
{
String
sql
=
SqlSpeller
.
insertMultiTableMultiValuesWithColumns
(
tables
);
String
sql
=
SqlSpeller
.
insertMultiTableMultiValuesWithColumns
(
tables
);
logger
.
debug
(
"SQL >>> "
+
sql
);
return
template
.
update
(
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
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.Target
=
System.out
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录