Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6fecb25d
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看板
提交
6fecb25d
编写于
1月 27, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
c076d6ae
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
27 addition
and
420 deletion
+27
-420
tests/examples/JDBC/springbootdemo/pom.xml
tests/examples/JDBC/springbootdemo/pom.xml
+2
-4
tests/examples/JDBC/springbootdemo/readme.md
tests/examples/JDBC/springbootdemo/readme.md
+3
-3
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java
...ata/example/springbootdemo/SpringbootdemoApplication.java
+3
-5
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
.../example/springbootdemo/controller/WeatherController.java
+3
-3
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
...om/taosdata/example/springbootdemo/dao/WeatherMapper.java
+2
-2
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
...com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
+3
-3
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
...a/com/taosdata/example/springbootdemo/domain/Weather.java
+1
-1
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
...osdata/example/springbootdemo/service/WeatherService.java
+3
-3
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java
...jdbc/springbootdemo/controller/RainStationController.java
+0
-28
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java
.../com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java
+0
-15
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml
...a/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml
+0
-44
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java
.../com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java
+0
-9
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml
...a/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml
+0
-11
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java
...ava/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java
+0
-8
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml
...java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml
+0
-21
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java
...om/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java
+0
-28
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java
...ava/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java
+0
-64
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java
...om/taosdata/jdbc/springbootdemo/domain/TableMetadata.java
+0
-43
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java
.../com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java
+0
-27
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java
...sdata/jdbc/springbootdemo/service/RainStationService.java
+0
-72
tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
.../springbootdemo/src/main/resources/application.properties
+7
-13
tests/examples/JDBC/springbootdemo/src/test/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplicationTests.java
...a/jdbc/springbootdemo/SpringbootdemoApplicationTests.java
+0
-13
未找到文件。
tests/examples/JDBC/springbootdemo/pom.xml
浏览文件 @
6fecb25d
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<version>
2.2.1.RELEASE
</version>
<version>
2.2.1.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
<relativePath/>
<!-- lookup parent from repository -->
</parent>
</parent>
<groupId>
com.taosdata.
jdbc
</groupId>
<groupId>
com.taosdata.
example
</groupId>
<artifactId>
springbootdemo
</artifactId>
<artifactId>
springbootdemo
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
0.0.1-SNAPSHOT
</version>
<name>
springbootdemo
</name>
<name>
springbootdemo
</name>
...
@@ -63,7 +63,7 @@
...
@@ -63,7 +63,7 @@
<dependency>
<dependency>
<groupId>
com.taosdata.jdbc
</groupId>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.
4
</version>
<version>
2.0.
18
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
@@ -71,8 +71,6 @@
...
@@ -71,8 +71,6 @@
<artifactId>
druid-spring-boot-starter
</artifactId>
<artifactId>
druid-spring-boot-starter
</artifactId>
<version>
1.1.17
</version>
<version>
1.1.17
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
tests/examples/JDBC/springbootdemo/readme.md
浏览文件 @
6fecb25d
...
@@ -47,7 +47,7 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug
...
@@ -47,7 +47,7 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug
*
插入单条记录
*
插入单条记录
```
xml
```
xml
<!-- weatherMapper.xml -->
<!-- weatherMapper.xml -->
<insert
id=
"insert"
parameterType=
"
com.taosdata.jdbc.springbootdemo.domain.
Weather"
>
<insert
id=
"insert"
parameterType=
"Weather"
>
insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT})
insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT})
</insert>
</insert>
```
```
...
@@ -67,9 +67,9 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug
...
@@ -67,9 +67,9 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug
<?xml version="1.0" encoding="UTF-8"?>
<?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">
<!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"
>
<mapper
namespace=
"WeatherMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"
com.taosdata.jdbc.springbootdemo.domain.
Weather"
>
<resultMap
id=
"BaseResultMap"
type=
"Weather"
>
<id
column=
"ts"
jdbcType=
"TIMESTAMP"
property=
"ts"
/>
<id
column=
"ts"
jdbcType=
"TIMESTAMP"
property=
"ts"
/>
<result
column=
"temperature"
jdbcType=
"INTEGER"
property=
"temperature"
/>
<result
column=
"temperature"
jdbcType=
"INTEGER"
property=
"temperature"
/>
<result
column=
"humidity"
jdbcType=
"FLOAT"
property=
"humidity"
/>
<result
column=
"humidity"
jdbcType=
"FLOAT"
property=
"humidity"
/>
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
jdbc
/springbootdemo/SpringbootdemoApplication.java
→
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
example
/springbootdemo/SpringbootdemoApplication.java
浏览文件 @
6fecb25d
package
com.taosdata.
jdbc
.springbootdemo
;
package
com.taosdata.
example
.springbootdemo
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@MapperScan
(
basePackages
=
{
"com.taosdata.
jdbc
.springbootdemo.dao"
})
@MapperScan
(
basePackages
=
{
"com.taosdata.
example
.springbootdemo.dao"
})
@SpringBootApplication
@SpringBootApplication
public
class
cd
{
public
class
SpringbootdemoApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SpringbootdemoApplication
.
class
,
args
);
SpringApplication
.
run
(
SpringbootdemoApplication
.
class
,
args
);
}
}
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
jdbc
/springbootdemo/controller/WeatherController.java
→
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
example
/springbootdemo/controller/WeatherController.java
浏览文件 @
6fecb25d
package
com.taosdata.
jdbc
.springbootdemo.controller
;
package
com.taosdata.
example
.springbootdemo.controller
;
import
com.taosdata.
jdbc
.springbootdemo.domain.Weather
;
import
com.taosdata.
example
.springbootdemo.domain.Weather
;
import
com.taosdata.
jdbc
.springbootdemo.service.WeatherService
;
import
com.taosdata.
example
.springbootdemo.service.WeatherService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
jdbc
/springbootdemo/dao/WeatherMapper.java
→
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
example
/springbootdemo/dao/WeatherMapper.java
浏览文件 @
6fecb25d
package
com.taosdata.
jdbc
.springbootdemo.dao
;
package
com.taosdata.
example
.springbootdemo.dao
;
import
com.taosdata.
jdbc
.springbootdemo.domain.Weather
;
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
;
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
jdbc
/springbootdemo/dao/WeatherMapper.xml
→
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
example
/springbootdemo/dao/WeatherMapper.xml
浏览文件 @
6fecb25d
<?xml version="1.0" encoding="UTF-8"?>
<?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">
<!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"
>
<mapper
namespace=
"com.taosdata.
example
.springbootdemo.dao.WeatherMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.taosdata.
jdbc
.springbootdemo.domain.Weather"
>
<resultMap
id=
"BaseResultMap"
type=
"com.taosdata.
example
.springbootdemo.domain.Weather"
>
<id
column=
"ts"
jdbcType=
"TIMESTAMP"
property=
"ts"
/>
<id
column=
"ts"
jdbcType=
"TIMESTAMP"
property=
"ts"
/>
<result
column=
"temperature"
jdbcType=
"INTEGER"
property=
"temperature"
/>
<result
column=
"temperature"
jdbcType=
"INTEGER"
property=
"temperature"
/>
<result
column=
"humidity"
jdbcType=
"FLOAT"
property=
"humidity"
/>
<result
column=
"humidity"
jdbcType=
"FLOAT"
property=
"humidity"
/>
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
</if>
</if>
</select>
</select>
<insert
id=
"insert"
parameterType=
"com.taosdata.
jdbc
.springbootdemo.domain.Weather"
>
<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 into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT})
</insert>
</insert>
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
jdbc
/springbootdemo/domain/Weather.java
→
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
example
/springbootdemo/domain/Weather.java
浏览文件 @
6fecb25d
package
com.taosdata.
jdbc
.springbootdemo.domain
;
package
com.taosdata.
example
.springbootdemo.domain
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
jdbc
/springbootdemo/service/WeatherService.java
→
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/
example
/springbootdemo/service/WeatherService.java
浏览文件 @
6fecb25d
package
com.taosdata.
jdbc
.springbootdemo.service
;
package
com.taosdata.
example
.springbootdemo.service
;
import
com.taosdata.
jdbc
.springbootdemo.dao.WeatherMapper
;
import
com.taosdata.
example
.springbootdemo.dao.WeatherMapper
;
import
com.taosdata.
jdbc
.springbootdemo.domain.Weather
;
import
com.taosdata.
example
.springbootdemo.domain.Weather
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo.controller
;
import
com.taosdata.jdbc.springbootdemo.domain.Rainfall
;
import
com.taosdata.jdbc.springbootdemo.service.RainStationService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@RestController
@RequestMapping
(
"/rainstation"
)
public
class
RainStationController
{
@Autowired
private
RainStationService
service
;
@GetMapping
(
"/init"
)
public
boolean
init
()
{
service
.
init
();
service
.
createTable
();
return
true
;
}
@PostMapping
(
"/insert"
)
public
int
insert
(
@RequestBody
Rainfall
rainfall
){
return
service
.
insert
(
rainfall
);
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo.dao
;
import
java.util.Map
;
public
interface
DatabaseMapper
{
int
createDatabase
(
String
dbname
);
int
dropDatabase
(
String
dbname
);
int
creatDatabaseWithParameters
(
Map
<
String
,
String
>
map
);
int
useDatabase
(
String
dbname
);
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml
已删除
100644 → 0
浏览文件 @
c076d6ae
<?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.DatabaseMapper"
>
<update
id=
"createDatabase"
parameterType=
"java.lang.String"
>
create database if not exists ${dbname}
</update>
<update
id=
"dropDatabase"
parameterType=
"java.lang.String"
>
DROP database if exists ${dbname}
</update>
<update
id=
"creatDatabaseWithParameters"
parameterType=
"map"
>
CREATE database if not EXISTS ${dbname}
<if
test=
"keep != null"
>
KEEP ${keep}
</if>
<if
test=
"days != null"
>
DAYS ${days}
</if>
<if
test=
"replica != null"
>
REPLICA ${replica}
</if>
<if
test=
"cache != null"
>
cache ${cache}
</if>
<if
test=
"blocks != null"
>
blocks ${blocks}
</if>
<if
test=
"minrows != null"
>
minrows ${minrows}
</if>
<if
test=
"maxrows != null"
>
maxrows ${maxrows}
</if>
</update>
<update
id=
"useDatabase"
parameterType=
"java.lang.String"
>
use ${dbname}
</update>
</mapper>
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo.dao
;
import
java.util.Map
;
public
interface
RainfallMapper
{
int
save
(
Map
<
String
,
Object
>
map
);
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml
已删除
100644 → 0
浏览文件 @
c076d6ae
<?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.RainfallMapper"
>
<insert
id=
"save"
parameterType=
"map"
>
INSERT INTO ${table} using ${dbname}.${stable} tags(#{values.station_code}, #{values.station_name}) (ts, name, code, rainfall) values (#{values.ts}, #{values.name}, #{values.code}, #{values.rainfall})
</insert>
</mapper>
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo.dao
;
import
com.taosdata.jdbc.springbootdemo.domain.TableMetadata
;
public
interface
TableMapper
{
boolean
createSTable
(
TableMetadata
tableMetadata
);
}
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml
已删除
100644 → 0
浏览文件 @
c076d6ae
<?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.TableMapper"
>
<update
id=
"createSTable"
parameterType=
"com.taosdata.jdbc.springbootdemo.domain.TableMetadata"
>
create table if not exists ${dbname}.${tablename}
<foreach
collection=
"fields"
item=
"field"
index=
"index"
open=
"("
close=
")"
separator=
","
>
${field.name} ${field.type}
</foreach>
TAGS
<foreach
collection=
"tags"
item=
"tag"
index=
"index"
open=
"("
close=
")"
separator=
","
>
${tag.name} ${tag.type}
</foreach>
</update>
<update
id=
"dropTable"
parameterType=
"java.lang.String"
>
drop ${tablename}
</update>
</mapper>
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo.domain
;
public
class
FieldMetadata
{
private
String
name
;
private
String
type
;
public
FieldMetadata
(
String
name
,
String
type
)
{
this
.
name
=
name
;
this
.
type
=
type
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo.domain
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.sql.Timestamp
;
public
class
Rainfall
{
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss.SSS"
,
timezone
=
"GMT+8"
)
private
Timestamp
ts
;
private
String
name
;
private
String
code
;
private
float
rainfall
;
private
String
station_code
;
private
String
station_name
;
public
Timestamp
getTs
()
{
return
ts
;
}
public
void
setTs
(
Timestamp
ts
)
{
this
.
ts
=
ts
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
float
getRainfall
()
{
return
rainfall
;
}
public
void
setRainfall
(
float
rainfall
)
{
this
.
rainfall
=
rainfall
;
}
public
String
getStation_code
()
{
return
station_code
;
}
public
void
setStation_code
(
String
station_code
)
{
this
.
station_code
=
station_code
;
}
public
String
getStation_name
()
{
return
station_name
;
}
public
void
setStation_name
(
String
station_name
)
{
this
.
station_name
=
station_name
;
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo.domain
;
import
java.util.List
;
public
class
TableMetadata
{
private
String
dbname
;
private
String
tablename
;
private
List
<
FieldMetadata
>
fields
;
private
List
<
TagMetadata
>
tags
;
public
String
getDbname
()
{
return
dbname
;
}
public
void
setDbname
(
String
dbname
)
{
this
.
dbname
=
dbname
;
}
public
String
getTablename
()
{
return
tablename
;
}
public
void
setTablename
(
String
tablename
)
{
this
.
tablename
=
tablename
;
}
public
List
<
FieldMetadata
>
getFields
()
{
return
fields
;
}
public
void
setFields
(
List
<
FieldMetadata
>
fields
)
{
this
.
fields
=
fields
;
}
public
List
<
TagMetadata
>
getTags
()
{
return
tags
;
}
public
void
setTags
(
List
<
TagMetadata
>
tags
)
{
this
.
tags
=
tags
;
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo.domain
;
public
class
TagMetadata
{
private
String
name
;
private
String
type
;
public
TagMetadata
(
String
name
,
String
type
)
{
this
.
name
=
name
;
this
.
type
=
type
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo.service
;
import
com.taosdata.jdbc.springbootdemo.dao.DatabaseMapper
;
import
com.taosdata.jdbc.springbootdemo.dao.RainfallMapper
;
import
com.taosdata.jdbc.springbootdemo.dao.TableMapper
;
import
com.taosdata.jdbc.springbootdemo.domain.FieldMetadata
;
import
com.taosdata.jdbc.springbootdemo.domain.Rainfall
;
import
com.taosdata.jdbc.springbootdemo.domain.TableMetadata
;
import
com.taosdata.jdbc.springbootdemo.domain.TagMetadata
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
RainStationService
{
@Autowired
private
DatabaseMapper
databaseMapper
;
@Autowired
private
TableMapper
tableMapper
;
@Autowired
private
RainfallMapper
rainfallMapper
;
public
boolean
init
()
{
databaseMapper
.
dropDatabase
(
"rainstation"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"dbname"
,
"rainstation"
);
map
.
put
(
"keep"
,
"36500"
);
map
.
put
(
"days"
,
"30"
);
map
.
put
(
"blocks"
,
"4"
);
databaseMapper
.
creatDatabaseWithParameters
(
map
);
databaseMapper
.
useDatabase
(
"rainstation"
);
return
true
;
}
public
boolean
createTable
()
{
TableMetadata
tableMetadata
=
new
TableMetadata
();
tableMetadata
.
setDbname
(
"rainstation"
);
tableMetadata
.
setTablename
(
"monitoring"
);
List
<
FieldMetadata
>
fields
=
new
ArrayList
<>();
fields
.
add
(
new
FieldMetadata
(
"ts"
,
"timestamp"
));
fields
.
add
(
new
FieldMetadata
(
"name"
,
"NCHAR(10)"
));
fields
.
add
(
new
FieldMetadata
(
"code"
,
" BINARY(8)"
));
fields
.
add
(
new
FieldMetadata
(
"rainfall"
,
"float"
));
tableMetadata
.
setFields
(
fields
);
List
<
TagMetadata
>
tags
=
new
ArrayList
<>();
tags
.
add
(
new
TagMetadata
(
"station_code"
,
"BINARY(8)"
));
tags
.
add
(
new
TagMetadata
(
"station_name"
,
"NCHAR(10)"
));
tableMetadata
.
setTags
(
tags
);
tableMapper
.
createSTable
(
tableMetadata
);
return
true
;
}
public
int
insert
(
Rainfall
rainfall
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"dbname"
,
"rainstation"
);
map
.
put
(
"table"
,
"S_53646"
);
map
.
put
(
"stable"
,
"monitoring"
);
map
.
put
(
"values"
,
rainfall
);
return
rainfallMapper
.
save
(
map
);
}
}
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
浏览文件 @
6fecb25d
# datasource config
# 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://
localhost:6030/log
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.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?user=root&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
# max wait time for get connection, ms
spring.datasource.druid.max-wait
=
30000
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.validation-query
=
select server_status();
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
mybatis.mapper-locations
=
classpath:mapper/*.xml
mybatis.mapper-locations
=
classpath:mapper/*.xml
...
...
tests/examples/JDBC/springbootdemo/src/test/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplicationTests.java
已删除
100644 → 0
浏览文件 @
c076d6ae
package
com.taosdata.jdbc.springbootdemo
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
SpringbootdemoApplicationTests
{
@Test
void
contextLoads
()
{
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录