Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
0b5729fb
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看板
提交
0b5729fb
编写于
3月 03, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
2a683c5b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
17 addition
and
37 deletion
+17
-37
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
.../example/springbootdemo/controller/WeatherController.java
+0
-11
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
...om/taosdata/example/springbootdemo/dao/WeatherMapper.java
+1
-3
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
...com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
+2
-9
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
...osdata/example/springbootdemo/service/WeatherService.java
+6
-6
tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
.../springbootdemo/src/main/resources/application.properties
+8
-8
未找到文件。
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
浏览文件 @
0b5729fb
...
...
@@ -48,17 +48,6 @@ public class WeatherController {
return
weatherService
.
save
(
temperature
,
humidity
);
}
/**
* upload multi weather info
*
* @param weatherList
* @return
*/
@PostMapping
(
"/batch"
)
public
int
batchSaveWeather
(
@RequestBody
List
<
Weather
>
weatherList
)
{
return
weatherService
.
save
(
weatherList
);
}
@GetMapping
(
"/count"
)
public
int
count
()
{
return
weatherService
.
count
();
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
浏览文件 @
0b5729fb
...
...
@@ -11,14 +11,12 @@ public interface WeatherMapper {
void
createSuperTable
();
void
createTable
();
void
createTable
(
Weather
weather
);
List
<
Weather
>
select
(
@Param
(
"limit"
)
Long
limit
,
@Param
(
"offset"
)
Long
offset
);
int
insert
(
Weather
weather
);
int
batchInsert
(
List
<
Weather
>
weatherList
);
int
count
();
List
<
String
>
getSubTables
();
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
浏览文件 @
0b5729fb
...
...
@@ -10,7 +10,7 @@
</resultMap>
<update
id=
"createDB"
>
create database if not exists test
;
create database if not exists test
</update>
<update
id=
"createSuperTable"
>
...
...
@@ -32,14 +32,7 @@
</select>
<insert
id=
"insert"
parameterType=
"com.taosdata.example.springbootdemo.domain.Weather"
>
insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT})
</insert>
<insert
id=
"batchInsert"
parameterType=
"java.util.List"
>
insert into test.weather (ts, temperature, humidity) values
<foreach
separator=
" "
collection=
"list"
item=
"weather"
index=
"index"
>
(now + #{index}a, #{weather.temperature}, #{weather.humidity})
</foreach>
insert into test.t#{groupId} (ts, temperature, humidity) values (#{ts}, #{temperature}, #{humidity})
</insert>
<select
id=
"getSubTables"
>
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
浏览文件 @
0b5729fb
...
...
@@ -15,15 +15,19 @@ public class WeatherService {
@Autowired
private
WeatherMapper
weatherMapper
;
private
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
private
String
[]
locations
=
{
"北京"
,
"上海"
,
"广州"
,
"深圳"
,
"天津"
};
public
int
init
()
{
weatherMapper
.
createDB
();
weatherMapper
.
createSuperTable
();
weatherMapper
.
createTable
();
long
ts
=
System
.
currentTimeMillis
();
int
count
=
0
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
count
+=
weatherMapper
.
insert
(
new
Weather
(
new
Timestamp
(
ts
+
(
1000
*
i
)),
30
*
random
.
nextFloat
(),
random
.
nextInt
(
100
)));
Weather
weather
=
new
Weather
(
new
Timestamp
(
ts
+
(
1000
*
i
)),
30
*
random
.
nextFloat
(),
random
.
nextInt
(
100
));
weather
.
setLocation
(
locations
[
random
.
nextInt
(
locations
.
length
)]);
weather
.
setGroupId
(
i
%
locations
.
length
);
weatherMapper
.
createTable
(
weather
);
count
+=
weatherMapper
.
insert
(
weather
);
}
return
count
;
}
...
...
@@ -40,10 +44,6 @@ public class WeatherService {
return
weatherMapper
.
insert
(
weather
);
}
public
int
save
(
List
<
Weather
>
weatherList
)
{
return
weatherMapper
.
batchInsert
(
weatherList
);
}
public
int
count
()
{
return
weatherMapper
.
count
();
}
...
...
tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
浏览文件 @
0b5729fb
# datasource config - JDBC-JNI
spring.datasource.driver-class-name
=
com.taosdata.jdbc.TSDBDriver
spring.datasource.url
=
jdbc:TAOS://127.0.0.1:6030/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
spring.datasource.username
=
root
spring.datasource.password
=
taosdata
# datasource config - JDBC-RESTful
#spring.datasource.driver-class-name=com.taosdata.jdbc.rs.RestfulDriver
#spring.datasource.url=jdbc:TAOS-RS://localhost:6041/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
#spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver
#spring.datasource.url=jdbc:TAOS://127.0.0.1:6030/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
#spring.datasource.username=root
#spring.datasource.password=taosdata
# datasource config - JDBC-RESTful
spring.datasource.driver-class-name
=
com.taosdata.jdbc.rs.RestfulDriver
spring.datasource.url
=
jdbc:TAOS-RS://master:6041/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
spring.datasource.username
=
root
spring.datasource.password
=
taosdata
spring.datasource.druid.initial-size
=
5
spring.datasource.druid.min-idle
=
5
spring.datasource.druid.max-active
=
5
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录