Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ba22bff2
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看板
提交
ba22bff2
编写于
3月 03, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
0b5729fb
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
39 addition
and
13 deletion
+39
-13
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
.../example/springbootdemo/controller/WeatherController.java
+6
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
...om/taosdata/example/springbootdemo/dao/WeatherMapper.java
+6
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
...com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
+11
-3
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
...osdata/example/springbootdemo/service/WeatherService.java
+8
-2
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
浏览文件 @
ba22bff2
...
@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@RequestMapping
(
"/weather"
)
@RequestMapping
(
"/weather"
)
@RestController
@RestController
...
@@ -58,4 +59,9 @@ public class WeatherController {
...
@@ -58,4 +59,9 @@ public class WeatherController {
return
weatherService
.
getSubTables
();
return
weatherService
.
getSubTables
();
}
}
@GetMapping
(
"/avg"
)
public
Map
avg
()
{
return
weatherService
.
avg
();
}
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
浏览文件 @
ba22bff2
...
@@ -4,9 +4,12 @@ import com.taosdata.example.springbootdemo.domain.Weather;
...
@@ -4,9 +4,12 @@ import com.taosdata.example.springbootdemo.domain.Weather;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
public
interface
WeatherMapper
{
public
interface
WeatherMapper
{
void
dropDB
();
void
createDB
();
void
createDB
();
void
createSuperTable
();
void
createSuperTable
();
...
@@ -20,4 +23,7 @@ public interface WeatherMapper {
...
@@ -20,4 +23,7 @@ public interface WeatherMapper {
int
count
();
int
count
();
List
<
String
>
getSubTables
();
List
<
String
>
getSubTables
();
Map
avg
();
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
浏览文件 @
ba22bff2
...
@@ -9,16 +9,20 @@
...
@@ -9,16 +9,20 @@
<result
column=
"humidity"
jdbcType=
"FLOAT"
property=
"humidity"
/>
<result
column=
"humidity"
jdbcType=
"FLOAT"
property=
"humidity"
/>
</resultMap>
</resultMap>
<update
id=
"dropDB"
>
drop database if exists test
</update>
<update
id=
"createDB"
>
<update
id=
"createDB"
>
create database if not exists test
create database if not exists test
</update>
</update>
<update
id=
"createSuperTable"
>
<update
id=
"createSuperTable"
>
create table if not exists test.weather(ts timestamp, temp
orary
float, humidity int) tags(location nchar(64), groupId int)
create table if not exists test.weather(ts timestamp, temp
erature
float, humidity int) tags(location nchar(64), groupId int)
</update>
</update>
<update
id=
"createTable"
parameterType=
"com.taosdata.example.springbootdemo.domain.Weather"
>
<update
id=
"createTable"
parameterType=
"com.taosdata.example.springbootdemo.domain.Weather"
>
create table test.t#{groupId} using test.weather tags(#{location}, #{groupId})
create table
if not exists
test.t#{groupId} using test.weather tags(#{location}, #{groupId})
</update>
</update>
<select
id=
"select"
resultMap=
"BaseResultMap"
>
<select
id=
"select"
resultMap=
"BaseResultMap"
>
...
@@ -32,7 +36,7 @@
...
@@ -32,7 +36,7 @@
</select>
</select>
<insert
id=
"insert"
parameterType=
"com.taosdata.example.springbootdemo.domain.Weather"
>
<insert
id=
"insert"
parameterType=
"com.taosdata.example.springbootdemo.domain.Weather"
>
insert into test.t#{groupId} (ts, temperature, humidity) values (#{ts},
#{temperature}, #
{humidity})
insert into test.t#{groupId} (ts, temperature, humidity) values (#{ts},
${temperature}, $
{humidity})
</insert>
</insert>
<select
id=
"getSubTables"
>
<select
id=
"getSubTables"
>
...
@@ -43,4 +47,8 @@
...
@@ -43,4 +47,8 @@
select count(*) from test.weather
select count(*) from test.weather
</select>
</select>
<select
id=
"avg"
resultType=
"map"
>
select avg(temperature), avg(humidity)from test.weather interval(1m)
</select>
</mapper>
</mapper>
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
浏览文件 @
ba22bff2
...
@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
...
@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Random
;
@Service
@Service
...
@@ -18,12 +19,14 @@ public class WeatherService {
...
@@ -18,12 +19,14 @@ public class WeatherService {
private
String
[]
locations
=
{
"北京"
,
"上海"
,
"广州"
,
"深圳"
,
"天津"
};
private
String
[]
locations
=
{
"北京"
,
"上海"
,
"广州"
,
"深圳"
,
"天津"
};
public
int
init
()
{
public
int
init
()
{
weatherMapper
.
dropDB
();
weatherMapper
.
createDB
();
weatherMapper
.
createDB
();
weatherMapper
.
createSuperTable
();
weatherMapper
.
createSuperTable
();
long
ts
=
System
.
currentTimeMillis
();
long
ts
=
System
.
currentTimeMillis
();
long
thirtySec
=
1000
*
30
;
int
count
=
0
;
int
count
=
0
;
for
(
int
i
=
0
;
i
<
1
0
;
i
++)
{
for
(
int
i
=
0
;
i
<
2
0
;
i
++)
{
Weather
weather
=
new
Weather
(
new
Timestamp
(
ts
+
(
1000
*
i
)),
30
*
random
.
nextFloat
(),
random
.
nextInt
(
100
));
Weather
weather
=
new
Weather
(
new
Timestamp
(
ts
+
(
thirtySec
*
i
)),
30
*
random
.
nextFloat
(),
random
.
nextInt
(
100
));
weather
.
setLocation
(
locations
[
random
.
nextInt
(
locations
.
length
)]);
weather
.
setLocation
(
locations
[
random
.
nextInt
(
locations
.
length
)]);
weather
.
setGroupId
(
i
%
locations
.
length
);
weather
.
setGroupId
(
i
%
locations
.
length
);
weatherMapper
.
createTable
(
weather
);
weatherMapper
.
createTable
(
weather
);
...
@@ -52,4 +55,7 @@ public class WeatherService {
...
@@ -52,4 +55,7 @@ public class WeatherService {
return
weatherMapper
.
getSubTables
();
return
weatherMapper
.
getSubTables
();
}
}
public
Map
avg
()
{
return
weatherMapper
.
avg
();
}
}
}
tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
浏览文件 @
ba22bff2
# datasource config - JDBC-JNI
# datasource config - JDBC-JNI
#spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver
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.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.username
=
root
spring.datasource.password
=
taosdata
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.initial-size
=
5
spring.datasource.druid.min-idle
=
5
spring.datasource.druid.min-idle
=
5
spring.datasource.druid.max-active
=
5
spring.datasource.druid.max-active
=
5
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录