## TDengine SpringBoot + Mybatis Demo ## 需要提前创建 test 数据库 ### 配置 application.properties ```properties # datasource config spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver spring.datasource.url=jdbc:TAOS://127.0.0.1:6030/test 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 # max wait time for get connection, ms 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.time-between-eviction-runs-millis=60000 spring.datasource.druid.min-evictable-idle-time-millis=600000 spring.datasource.druid.max-evictable-idle-time-millis=900000 # mybatis mybatis.mapper-locations=classpath:mapper/*.xml # log logging.level.com.taosdata.jdbc.springbootdemo.dao=debug ``` ### 主要功能 * 创建数据库和表 ```xml create database if not exists test; create table if not exists test.weather(ts timestamp, temperature int, humidity float); ``` * 插入单条记录 ```xml insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT}) ``` * 插入多条记录 ```xml insert into test.weather (ts, temperature, humidity) values (now + #{index}a, #{weather.temperature}, #{weather.humidity}) ``` * 分页查询 ```xml ts, temperature, humidity ```