提交 d47f7a5f 编写于 作者: xiaonannet's avatar xiaonannet

superTableCreateOrUpdate

上级 26050f23
......@@ -25,6 +25,8 @@
设备地理位置可视化查看,可视化大屏。
TDengine时序数据库超级表设计概念:每个设备一张表,每类设备一个超级表。
## 系统模块
~~~
......
# spring配置
spring:
redis:
host: 127.0.0.1
port: 6379
password: thinglinks
datasource:
druid:
stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456
dynamic:
druid:
initial-size: 5
min-idle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat,slf4j
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
# 主库数据源
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/wgcloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: wgcloud
password: wgcloud
# 从库数据源
# slave:
# username:
# password:
# url:
# driver-class-name:
# seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
rocketmq:
# 进程
topic1: thinglinks_collection_process
# 系统
topic2: thinglinks_collection_system
name-server: 127.0.0.1:9876
producer:
group: thinglinks
\ No newline at end of file
......@@ -17,6 +17,14 @@ spring:
aop:
auto: true
proxy-target-class: true
# rocketmq地址
rocketmq:
name-server: 127.0.0.1:9876
# 默认的消息组
producer:
group: thinglinks
mybatis:
mapper-locations: classpath:mapper/*.xml
logging:
......
此差异已折叠。
## TDengine SpringBoot + Mybatis Demo
## TDengine SpringBoot + Mybatis Demo 超级表设计概念:每个设备一张表,每类设备一个超级表 ;命名规则 : 产品类型_产品标识_服务名称_设备标识
### 配置 application.properties
```properties
# datasource config
spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver
spring.datasource.url=jdbc:TAOS://127.0.0.1:6030/log
spring.datasource.url=jdbc:TAOS://127.0.0.1:6030/thinglinks
spring.datasource.username=root
spring.datasource.password=taosdata
......@@ -16,9 +16,9 @@ spring.datasource.druid.max-wait=60000
spring.datasource.druid.validation-query=select server_status();
spring.datasource.druid.validation-query-timeout=5000
spring.datasource.druid.test-on-borrow=false
spring.datasource.druid.test-on-return=false
spring.datasource.druid.test-while-idle=true
spring.datasource.druid.thinglinks-on-borrow=false
spring.datasource.druid.thinglinks-on-return=false
spring.datasource.druid.thinglinks-while-idle=true
spring.datasource.druid.time-between-eviction-runs-millis=60000
spring.datasource.druid.min-evictable-idle-time-millis=600000
spring.datasource.druid.max-evictable-idle-time-millis=900000
......@@ -36,11 +36,11 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug
```xml
<!-- weatherMapper.xml -->
<update id="createDB" >
create database if not exists test;
create database if not exists thinglinks;
</update>
<update id="createTable" >
create table if not exists test.weather(ts timestamp, temperature int, humidity float);
create table if not exists thinglinks.weather(ts timestamp, temperature int, humidity float);
</update>
```
......@@ -48,14 +48,14 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug
```xml
<!-- weatherMapper.xml -->
<insert id="insert" parameterType="Weather" >
insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT})
insert into thinglinks.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT})
</insert>
```
* 插入多条记录
```xml
<!-- weatherMapper.xml -->
<insert id="batchInsert" parameterType="java.util.List" >
insert into test.weather (ts, temperature, humidity) values
insert into thinglinks.weather (ts, temperature, humidity) values
<foreach separator=" " collection="list" item="weather" index="index" >
(now + #{index}a, #{weather.temperature}, #{weather.humidity})
</foreach>
......@@ -82,12 +82,12 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug
<select id="select" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from test.weather
from thinglinks.weather
order by ts desc
<if test="limit != null">
<if thinglinks="limit != null">
limit #{limit,jdbcType=BIGINT}
</if>
<if test="offset != null">
<if thinglinks="offset != null">
offset #{offset,jdbcType=BIGINT}
</if>
</select>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册