## 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.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=describe log.dn
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
<!-- weatherMapper.xml -->
<update id="createDB" >
create database if not exists test;
</update>
<update id="createTable" >
create table if not exists test.weather(ts timestamp, temperature int, humidity float);
</update>
```
* 插入单条记录
```xml
<!-- weatherMapper.xml -->
<insert id="insert" parameterType="com.taosdata.jdbc.springbootdemo.domain.Weather" >
insert into test.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
<foreach separator=" " collection="list" item="weather" index="index" >
(now + #{index}a, #{weather.temperature}, #{weather.humidity})
</foreach>
</insert>
```
* 分页查询
```xml
<!-- weatherMapper.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.taosdata.jdbc.springbootdemo.dao.WeatherMapper">
<resultMap id="BaseResultMap" type="com.taosdata.jdbc.springbootdemo.domain.Weather">
<id column="ts" jdbcType="TIMESTAMP" property="ts" />
<result column="temperature" jdbcType="INTEGER" property="temperature" />
<result column="humidity" jdbcType="FLOAT" property="humidity" />
</resultMap>
<sql id="Base_Column_List">
ts, temperature, humidity
</sql>
<select id="select" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from test.weather
order by ts desc
<if test="limit != null">
limit #{limit,jdbcType=BIGINT}
</if>
<if test="offset != null">
offset #{offset,jdbcType=BIGINT}
</if>
</select>
</mapper>
```
没有合适的资源?快使用搜索试试~ 我知道了~
springbootdemo.rar
共140个文件
xml:103个
java:12个
class:11个
需积分: 47 77 下载量 118 浏览量
2020-08-18
19:04:13
上传
评论 2
收藏 114KB RAR 举报
温馨提示
springboot集成mysql、TDengine双数据库Demo,利用mybatis进行sql管理;下载使用前,请确保是否已存在mysql以及TDengine数据库环境。 TDengine是涛思数据专为物联网、车联网、工业互联网、IT运维等设计和优化的大数据平台。除核心的快10倍以上的时序数据库功能外,还提供缓存、数据订阅、流式计算等功能,最大程度减少研发和运维的复杂度,且核心代码,包括集群功能全部开源。
资源推荐
资源详情
资源评论
收起资源包目录
springbootdemo.rar (140个子文件)
application.properties.bak 969B
application.properties.bak 969B
MysqlServerConfig.class 3KB
TDengineServerConfig.class 3KB
WeatherController.class 2KB
WeatherService.class 2KB
MysqlController.class 1KB
Weather.class 1KB
SpringbootdemoApplication.class 912B
WeatherMapper.class 802B
MysqlService.class 753B
SpringbootdemoApplicationTests.class 593B
MysqlMapper.class 272B
mvnw.cmd 6KB
.gitignore 299B
.gitignore 0B
springbootdemo.iml 12KB
maven-wrapper.jar 50KB
MavenWrapperDownloader.java 5KB
MysqlServerConfig.java 2KB
TDengineServerConfig.java 2KB
WeatherController.java 1KB
WeatherService.java 999B
MysqlController.java 718B
Weather.java 631B
MysqlService.java 490B
SpringbootdemoApplication.java 477B
WeatherMapper.java 430B
MysqlMapper.java 259B
SpringbootdemoApplicationTests.java 241B
spring-configuration-metadata.json 508B
springbootdemo.kotlin_module 16B
readme.md 3KB
mvnw 10KB
maven-wrapper.properties 218B
workspace.xml 10KB
uiDesigner.xml 9KB
pom.xml 3KB
WeatherMapper.xml 2KB
WeatherMapper.xml 2KB
jarRepositories.xml 879B
compiler.xml 833B
Maven__org_springframework_boot_spring_boot_configuration_processor_2_2_1_RELEASE.xml 804B
Maven__org_springframework_boot_spring_boot_starter_validation_2_2_1_RELEASE.xml 769B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_2_1_RELEASE.xml 769B
Maven__org_springframework_boot_spring_boot_starter_data_jdbc_2_2_1_RELEASE.xml 762B
Maven__org_springframework_boot_spring_boot_starter_thymeleaf_2_2_1_RELEASE.xml 762B
Maven__org_springframework_boot_spring_boot_starter_logging_2_2_1_RELEASE.xml 748B
Maven__org_springframework_boot_spring_boot_starter_tomcat_2_2_1_RELEASE.xml 741B
Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_10_0.xml 736B
Maven__org_springframework_boot_spring_boot_autoconfigure_2_2_1_RELEASE.xml 734B
Maven__org_mybatis_spring_boot_mybatis_spring_boot_autoconfigure_2_1_1.xml 730B
Maven__org_springframework_boot_spring_boot_starter_json_2_2_1_RELEASE.xml 727B
Maven__org_springframework_boot_spring_boot_starter_jdbc_2_2_1_RELEASE.xml 727B
Maven__org_springframework_boot_spring_boot_starter_test_2_2_1_RELEASE.xml 727B
Maven__org_thymeleaf_extras_thymeleaf_extras_java8time_3_0_4_RELEASE.xml 725B
Maven__org_springframework_boot_spring_boot_starter_web_2_2_1_RELEASE.xml 720B
Maven__org_springframework_data_spring_data_relational_1_1_1_RELEASE.xml 713B
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 700B
Maven__org_springframework_boot_spring_boot_devtools_2_2_1_RELEASE.xml 699B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_10_0.xml 695B
Maven__org_springframework_data_spring_data_commons_2_2_1_RELEASE.xml 692B
Maven__org_springframework_boot_spring_boot_starter_2_2_1_RELEASE.xml 692B
Maven__org_mybatis_spring_boot_mybatis_spring_boot_starter_2_1_1.xml 688B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_10_0.xml 681B
Maven__org_hibernate_validator_hibernate_validator_6_0_18_Final.xml 681B
Maven__org_springframework_boot_spring_boot_test_2_2_1_RELEASE.xml 671B
Maven__org_springframework_data_spring_data_jdbc_1_1_1_RELEASE.xml 671B
Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_27.xml 660B
Maven__org_springframework_spring_expression_5_2_1_RELEASE.xml 658B
Maven__com_fasterxml_jackson_core_jackson_annotations_2_10_0.xml 651B
Maven__org_thymeleaf_thymeleaf_spring5_3_0_11_RELEASE.xml 641B
Maven__org_springframework_spring_context_5_2_1_RELEASE.xml 637B
Maven__org_springframework_boot_spring_boot_2_2_1_RELEASE.xml 636B
Maven__com_alibaba_druid_spring_boot_starter_1_1_17.xml 633B
Maven__org_junit_platform_junit_platform_commons_1_5_2.xml 633B
Maven__jakarta_annotation_jakarta_annotation_api_1_3_5.xml 633B
Maven__jakarta_activation_jakarta_activation_api_1_2_1.xml 633B
Maven__jakarta_validation_jakarta_validation_api_2_0_1.xml 633B
Maven__org_springframework_spring_webmvc_5_2_1_RELEASE.xml 630B
Maven__com_fasterxml_jackson_core_jackson_databind_2_10_0.xml 630B
Maven__org_junit_platform_junit_platform_engine_1_5_2.xml 626B
Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_27.xml 625B
Maven__org_springframework_spring_beans_5_2_1_RELEASE.xml 623B
Maven__org_springframework_spring_core_5_2_1_RELEASE.xml 616B
Maven__org_springframework_spring_jdbc_5_2_1_RELEASE.xml 616B
Maven__org_springframework_spring_test_5_2_1_RELEASE.xml 616B
Maven__org_junit_jupiter_junit_jupiter_params_5_5_2.xml 615B
Maven__org_junit_jupiter_junit_jupiter_engine_5_5_2.xml 615B
Maven__jakarta_xml_bind_jakarta_xml_bind_api_2_3_2.xml 611B
Maven__org_apache_tomcat_embed_tomcat_embed_el_9_0_27.xml 611B
Maven__org_springframework_spring_jcl_5_2_1_RELEASE.xml 609B
Maven__org_springframework_spring_aop_5_2_1_RELEASE.xml 609B
Maven__org_springframework_spring_web_5_2_1_RELEASE.xml 609B
Maven__org_jboss_logging_jboss_logging_3_4_1_Final.xml 608B
Maven__org_apache_logging_log4j_log4j_to_slf4j_2_12_1.xml 608B
Maven__org_springframework_spring_tx_5_2_1_RELEASE.xml 602B
Maven__com_fasterxml_jackson_core_jackson_core_2_10_0.xml 602B
Maven__org_mockito_mockito_junit_jupiter_3_1_0.xml 598B
Maven__org_junit_jupiter_junit_jupiter_api_5_5_2.xml 594B
共 140 条
- 1
- 2
资源评论
养家糊口的猫
- 粉丝: 68
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功