From 6fecb25da815875e8d13a3ebe0a0e96d2fa661bf Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 27 Jan 2021 19:25:59 +0800 Subject: [PATCH] change --- tests/examples/JDBC/springbootdemo/pom.xml | 6 +- tests/examples/JDBC/springbootdemo/readme.md | 6 +- .../SpringbootdemoApplication.java | 8 +-- .../controller/WeatherController.java | 6 +- .../springbootdemo/dao/WeatherMapper.java | 4 +- .../springbootdemo/dao/WeatherMapper.xml | 6 +- .../springbootdemo/domain/Weather.java | 2 +- .../service/WeatherService.java | 6 +- .../controller/RainStationController.java | 28 -------- .../springbootdemo/dao/DatabaseMapper.java | 15 ---- .../springbootdemo/dao/DatabaseMapper.xml | 44 ------------ .../springbootdemo/dao/RainfallMapper.java | 9 --- .../springbootdemo/dao/RainfallMapper.xml | 11 --- .../jdbc/springbootdemo/dao/TableMapper.java | 8 --- .../jdbc/springbootdemo/dao/TableMapper.xml | 21 ------ .../springbootdemo/domain/FieldMetadata.java | 28 -------- .../jdbc/springbootdemo/domain/Rainfall.java | 64 ----------------- .../springbootdemo/domain/TableMetadata.java | 43 ----------- .../springbootdemo/domain/TagMetadata.java | 27 ------- .../service/RainStationService.java | 72 ------------------- .../src/main/resources/application.properties | 20 ++---- .../SpringbootdemoApplicationTests.java | 13 ---- 22 files changed, 27 insertions(+), 420 deletions(-) rename tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/{jdbc => example}/springbootdemo/SpringbootdemoApplication.java (66%) rename tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/{jdbc => example}/springbootdemo/controller/WeatherController.java (87%) rename tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/{jdbc => example}/springbootdemo/dao/WeatherMapper.java (74%) rename tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/{jdbc => example}/springbootdemo/dao/WeatherMapper.xml (84%) rename tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/{jdbc => example}/springbootdemo/domain/Weather.java (93%) rename tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/{jdbc => example}/springbootdemo/service/WeatherService.java (82%) delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java delete mode 100644 tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java delete mode 100644 tests/examples/JDBC/springbootdemo/src/test/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplicationTests.java diff --git a/tests/examples/JDBC/springbootdemo/pom.xml b/tests/examples/JDBC/springbootdemo/pom.xml index 881ea0d6bf..52fb8caa90 100644 --- a/tests/examples/JDBC/springbootdemo/pom.xml +++ b/tests/examples/JDBC/springbootdemo/pom.xml @@ -8,7 +8,7 @@ 2.2.1.RELEASE - com.taosdata.jdbc + com.taosdata.example springbootdemo 0.0.1-SNAPSHOT springbootdemo @@ -63,7 +63,7 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.4 + 2.0.18 @@ -71,8 +71,6 @@ druid-spring-boot-starter 1.1.17 - - diff --git a/tests/examples/JDBC/springbootdemo/readme.md b/tests/examples/JDBC/springbootdemo/readme.md index ac3bb44ef9..67a28947d2 100644 --- a/tests/examples/JDBC/springbootdemo/readme.md +++ b/tests/examples/JDBC/springbootdemo/readme.md @@ -47,7 +47,7 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug * 插入单条记录 ```xml - + insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT}) ``` @@ -67,9 +67,9 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug - + - + diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplication.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java similarity index 66% rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplication.java rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java index f693214567..8066126d62 100644 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplication.java +++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java @@ -1,15 +1,13 @@ -package com.taosdata.jdbc.springbootdemo; +package com.taosdata.example.springbootdemo; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@MapperScan(basePackages = {"com.taosdata.jdbc.springbootdemo.dao"}) +@MapperScan(basePackages = {"com.taosdata.example.springbootdemo.dao"}) @SpringBootApplication -public class cd { - +public class SpringbootdemoApplication { public static void main(String[] args) { SpringApplication.run(SpringbootdemoApplication.class, args); } - } diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/WeatherController.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java similarity index 87% rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/WeatherController.java rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java index 56a58fbb4d..0e13f9284a 100644 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/WeatherController.java +++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java @@ -1,7 +1,7 @@ -package com.taosdata.jdbc.springbootdemo.controller; +package com.taosdata.example.springbootdemo.controller; -import com.taosdata.jdbc.springbootdemo.domain.Weather; -import com.taosdata.jdbc.springbootdemo.service.WeatherService; +import com.taosdata.example.springbootdemo.domain.Weather; +import com.taosdata.example.springbootdemo.service.WeatherService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java similarity index 74% rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.java rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java index 1e3db1f491..cae1a1aec0 100644 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.java +++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java @@ -1,6 +1,6 @@ -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 java.util.List; diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.xml b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml similarity index 84% rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.xml rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml index e894f9a658..a9bcda0b00 100644 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.xml +++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml @@ -1,9 +1,9 @@ - + - + @@ -34,7 +34,7 @@ - + insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT}) diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Weather.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java similarity index 93% rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Weather.java rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java index cd7de447ea..60565448ad 100644 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Weather.java +++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java @@ -1,4 +1,4 @@ -package com.taosdata.jdbc.springbootdemo.domain; +package com.taosdata.example.springbootdemo.domain; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/WeatherService.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java similarity index 82% rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/WeatherService.java rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java index b950a9a4e4..31ce8f1dd9 100644 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/WeatherService.java +++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java @@ -1,7 +1,7 @@ -package com.taosdata.jdbc.springbootdemo.service; +package com.taosdata.example.springbootdemo.service; -import com.taosdata.jdbc.springbootdemo.dao.WeatherMapper; -import com.taosdata.jdbc.springbootdemo.domain.Weather; +import com.taosdata.example.springbootdemo.dao.WeatherMapper; +import com.taosdata.example.springbootdemo.domain.Weather; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java deleted file mode 100644 index 844ac21bb8..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java +++ /dev/null @@ -1,28 +0,0 @@ -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); - } - -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java deleted file mode 100644 index a9266acb30..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.taosdata.jdbc.springbootdemo.dao; - -import java.util.Map; - -public interface DatabaseMapper { - - int createDatabase(String dbname); - - int dropDatabase(String dbname); - - int creatDatabaseWithParameters(Map map); - - int useDatabase(String dbname); - -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml deleted file mode 100644 index 329f75b582..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - create database if not exists ${dbname} - - - - DROP database if exists ${dbname} - - - - - CREATE database if not EXISTS ${dbname} - - KEEP ${keep} - - - DAYS ${days} - - - REPLICA ${replica} - - - cache ${cache} - - - blocks ${blocks} - - - minrows ${minrows} - - - maxrows ${maxrows} - - - - - use ${dbname} - - - \ No newline at end of file diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java deleted file mode 100644 index f0efbf40ba..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.taosdata.jdbc.springbootdemo.dao; - -import java.util.Map; - -public interface RainfallMapper { - - - int save(Map map); -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml deleted file mode 100644 index 319b4f3974..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - 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}) - - - - \ No newline at end of file diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java deleted file mode 100644 index 7601bf974c..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java +++ /dev/null @@ -1,8 +0,0 @@ -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 diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml deleted file mode 100644 index 5a272eadb4..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - create table if not exists ${dbname}.${tablename} - - ${field.name} ${field.type} - - TAGS - - ${tag.name} ${tag.type} - - - - - drop ${tablename} - - - \ No newline at end of file diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java deleted file mode 100644 index 619b5a303d..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java +++ /dev/null @@ -1,28 +0,0 @@ -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; - } -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java deleted file mode 100644 index 93e199d7e6..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java +++ /dev/null @@ -1,64 +0,0 @@ -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; - } -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java deleted file mode 100644 index 74bb434f08..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.taosdata.jdbc.springbootdemo.domain; - -import java.util.List; - -public class TableMetadata { - - private String dbname; - private String tablename; - private List fields; - private List 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 getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java deleted file mode 100644 index 755ecc0075..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java +++ /dev/null @@ -1,27 +0,0 @@ -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; - } -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java deleted file mode 100644 index 3ea63c1760..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java +++ /dev/null @@ -1,72 +0,0 @@ -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 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 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 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 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 diff --git a/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties b/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties index 683884fcdd..4fb68758c4 100644 --- a/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties +++ b/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties @@ -1,24 +1,18 @@ -# datasource config +# datasource config - JDBC-JNI 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.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.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.max-wait=30000 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 diff --git a/tests/examples/JDBC/springbootdemo/src/test/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplicationTests.java b/tests/examples/JDBC/springbootdemo/src/test/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplicationTests.java deleted file mode 100644 index 23a7420dab..0000000000 --- a/tests/examples/JDBC/springbootdemo/src/test/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.taosdata.jdbc.springbootdemo; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class SpringbootdemoApplicationTests { - - @Test - void contextLoads() { - } - -} -- GitLab