Skip to content

Commit fc876a2

Browse files
authored
add srpingboot starter to table model (#818)
1 parent b5bede9 commit fc876a2

File tree

4 files changed

+344
-0
lines changed

4 files changed

+344
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Spring Boot Starter
21+
22+
## 1. Overview
23+
The Spring Boot Starter is a core modular component in the Spring Boot ecosystem. It simplifies the integration of third-party technologies (such as databases, message queues, and security frameworks) with Spring Boot applications through predefined dependency sets and automated configuration mechanisms. Each Starter encapsulates the core libraries, default configurations, and conditional initialization logic required for specific functionalities. Developers only need to include the dependency to achieve "zero-configuration" integration, adhering to the "convention over configuration" principle.
24+
25+
The officially provided iotdb-spring-boot-starter by IoTDB is a standardized integration component designed for the Spring Boot ecosystem, enabling developers to quickly and efficiently connect with time-series databases. By simply adding the dependency, developers can leverage IoTDB functionalities or modules, significantly reducing the complexity of technical integration in time-series data scenarios. This is particularly suitable for applications involving IoT, industrial internet, and other high-frequency time-series data storage and analysis.
26+
27+
## 2. Usage Steps
28+
29+
### 2.1 Version Requirements
30+
31+
* `IoTDB: >=2.0.3`
32+
* `iotdb-spring-boot-starter: >=2.0.3`
33+
34+
### 2.2 Procedure
35+
36+
1. Install and start IoTDB, refer to [IoTDB QuickStart](../QuickStart/QuickStart.md)
37+
2. Add the Maven dependency to your project
38+
39+
```xml
40+
<dependency>
41+
<groupId>org.apache.iotdb</groupId>
42+
<artifactId>iotdb-spring-boot-starter</artifactId>
43+
<version>2.0.3</version>
44+
</dependency>
45+
```
46+
47+
3. Configure custom settings in `application.properties`:
48+
49+
```Properties
50+
# IoTDB service address (format: IP:Port)
51+
iotdb.session.url=127.0.0.1:6667
52+
# IoTDB username
53+
iotdb.session.username=root
54+
# IoTDB password
55+
iotdb.session.password=root
56+
# Default SQL dialect
57+
iotdb.session.sql-dialect=table
58+
# Default database
59+
iotdb.session.database=wind
60+
# Connection pool max size
61+
iotdb.session.max-size=10
62+
```
63+
64+
4. Use the target Bean via `@Autowired`, for example
65+
66+
```java
67+
@Autowired
68+
private ITableSessionPool ioTDBSessionPool;
69+
70+
public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException {
71+
ITableSession tableSession = ioTDBSessionPool.getSession();
72+
final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from table1 limit 10");
73+
while (sessionDataSet.hasNext()) {
74+
final RowRecord rowRecord = sessionDataSet.next();
75+
final List<Field> fields = rowRecord.getFields();
76+
for (Field field : fields) {
77+
System.out.print(field.getStringValue());
78+
}
79+
System.out.println();
80+
}
81+
}
82+
```
83+
84+
## 3. Usage Examples
85+
For detailed examples, refer to the source code [examples/iotdb-spring-boot-start](https://github.com/apache/iotdb-extras/tree/master/examples/iotdb-spring-boot-start)
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Spring Boot Starter
21+
22+
## 1. Overview
23+
The Spring Boot Starter is a core modular component in the Spring Boot ecosystem. It simplifies the integration of third-party technologies (such as databases, message queues, and security frameworks) with Spring Boot applications through predefined dependency sets and automated configuration mechanisms. Each Starter encapsulates the core libraries, default configurations, and conditional initialization logic required for specific functionalities. Developers only need to include the dependency to achieve "zero-configuration" integration, adhering to the "convention over configuration" principle.
24+
25+
The officially provided iotdb-spring-boot-starter by IoTDB is a standardized integration component designed for the Spring Boot ecosystem, enabling developers to quickly and efficiently connect with time-series databases. By simply adding the dependency, developers can leverage IoTDB functionalities or modules, significantly reducing the complexity of technical integration in time-series data scenarios. This is particularly suitable for applications involving IoT, industrial internet, and other high-frequency time-series data storage and analysis.
26+
27+
## 2. Usage Steps
28+
29+
### 2.1 Version Requirements
30+
31+
* `IoTDB: >=2.0.3`
32+
* `iotdb-spring-boot-starter: >=2.0.3`
33+
34+
### 2.2 Procedure
35+
36+
1. Install and start IoTDB, refer to [IoTDB QuickStart](../QuickStart/QuickStart.md)
37+
2. Add the Maven dependency to your project
38+
39+
```xml
40+
<dependency>
41+
<groupId>org.apache.iotdb</groupId>
42+
<artifactId>iotdb-spring-boot-starter</artifactId>
43+
<version>2.0.3</version>
44+
</dependency>
45+
```
46+
47+
3. Configure custom settings in `application.properties`:
48+
49+
```Properties
50+
# IoTDB service address (format: IP:Port)
51+
iotdb.session.url=127.0.0.1:6667
52+
# IoTDB username
53+
iotdb.session.username=root
54+
# IoTDB password
55+
iotdb.session.password=root
56+
# Default SQL dialect
57+
iotdb.session.sql-dialect=table
58+
# Default database
59+
iotdb.session.database=wind
60+
# Connection pool max size
61+
iotdb.session.max-size=10
62+
```
63+
64+
4. Use the target Bean via `@Autowired`, for example
65+
66+
```java
67+
@Autowired
68+
private ITableSessionPool ioTDBSessionPool;
69+
70+
public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException {
71+
ITableSession tableSession = ioTDBSessionPool.getSession();
72+
final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from table1 limit 10");
73+
while (sessionDataSet.hasNext()) {
74+
final RowRecord rowRecord = sessionDataSet.next();
75+
final List<Field> fields = rowRecord.getFields();
76+
for (Field field : fields) {
77+
System.out.print(field.getStringValue());
78+
}
79+
System.out.println();
80+
}
81+
}
82+
```
83+
84+
## 3. Usage Examples
85+
For detailed examples, refer to the source code [examples/iotdb-spring-boot-start](https://github.com/apache/iotdb-extras/tree/master/examples/iotdb-spring-boot-start)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Spring Boot Starter
21+
22+
## 1. 概述
23+
24+
Spring Boot Starter 是 Spring Boot 生态中的核心模块化组件,通过预定义依赖集合与自动化配置机制,简化第三方技术栈(如数据库、消息队列、安全框架)与 Spring Boot 应用的集成流程。每个 Starter 封装了特定功能所需的核心库、默认配置及条件化初始化逻辑,开发者仅需引入依赖即可实现“零配置”集成,遵循“约定优于配置”原则。
25+
26+
IoTDB 官方提供的 `iotdb-spring-boot-starter` 是专为 Spring Boot 生态设计的标准化集成组件,帮助开发者快速实现时序数据库的高效接入。开发者仅需引入依赖,即可使用 IoTDB 功能或模块,显著降低时序数据场景下的技术集成复杂度,适用于物联网、工业互联网等高频时序数据存储与分析场景。
27+
28+
## 2. 使用步骤
29+
30+
### 2.1 版本要求
31+
32+
* `IoTDB: >=2.0.3`
33+
* `iotdb-spring-boot-starter: >=2.0.3`
34+
35+
### 2.2 操作流程
36+
37+
1. 安装并启动 IoTDB , 可参考 [IoTDB 快速入门](../QuickStart/QuickStart.md)
38+
2. 在项目中添加 Maven 依赖
39+
40+
```xml
41+
<dependency>
42+
<groupId>org.apache.iotdb</groupId>
43+
<artifactId>iotdb-spring-boot-starter</artifactId>
44+
<version>2.0.3</version>
45+
</dependency>
46+
```
47+
48+
3.`application.properties` 文件中进行自定义配置
49+
50+
```Properties
51+
# IoTDB 服务地址(格式:IP:Port)
52+
iotdb.session.url=127.0.0.1:6667
53+
# IoTDB 用户名
54+
iotdb.session.username=root
55+
# IoTDB 用户密码
56+
iotdb.session.password=root
57+
# 指定连接的默认模式
58+
iotdb.session.sql-dialect=table
59+
# 指定连接的默认数据库
60+
iotdb.session.database=wind
61+
# 连接池最大连接数
62+
iotdb.session.max-size=10
63+
```
64+
65+
4. 通过 @Autowired 使用目标 Bean,例如
66+
67+
```java
68+
@Autowired
69+
private ITableSessionPool ioTDBSessionPool;
70+
71+
public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException {
72+
ITableSession tableSession = ioTDBSessionPool.getSession();
73+
final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from table1 limit 10");
74+
while (sessionDataSet.hasNext()) {
75+
final RowRecord rowRecord = sessionDataSet.next();
76+
final List<Field> fields = rowRecord.getFields();
77+
for (Field field : fields) {
78+
System.out.print(field.getStringValue());
79+
}
80+
System.out.println();
81+
}
82+
}
83+
```
84+
85+
## 3. 使用示例
86+
87+
详细的使用示例可参考源码 [examples/iotdb-spring-boot-start](https://github.com/apache/iotdb-extras/tree/master/examples/iotdb-spring-boot-start)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Spring Boot Starter
21+
22+
## 1. 概述
23+
24+
Spring Boot Starter 是 Spring Boot 生态中的核心模块化组件,通过预定义依赖集合与自动化配置机制,简化第三方技术栈(如数据库、消息队列、安全框架)与 Spring Boot 应用的集成流程。每个 Starter 封装了特定功能所需的核心库、默认配置及条件化初始化逻辑,开发者仅需引入依赖即可实现“零配置”集成,遵循“约定优于配置”原则。
25+
26+
IoTDB 官方提供的 `iotdb-spring-boot-starter` 是专为 Spring Boot 生态设计的标准化集成组件,帮助开发者快速实现时序数据库的高效接入。开发者仅需引入依赖,即可使用 IoTDB 功能或模块,显著降低时序数据场景下的技术集成复杂度,适用于物联网、工业互联网等高频时序数据存储与分析场景。
27+
28+
## 2. 使用步骤
29+
30+
### 2.1 版本要求
31+
32+
* `IoTDB: >=2.0.3`
33+
* `iotdb-spring-boot-starter: >=2.0.3`
34+
35+
### 2.2 操作流程
36+
37+
1. 安装并启动 IoTDB , 可参考 [IoTDB 快速入门](../QuickStart/QuickStart.md)
38+
2. 在项目中添加 Maven 依赖
39+
40+
```xml
41+
<dependency>
42+
<groupId>org.apache.iotdb</groupId>
43+
<artifactId>iotdb-spring-boot-starter</artifactId>
44+
<version>2.0.3</version>
45+
</dependency>
46+
```
47+
48+
3.`application.properties` 文件中进行自定义配置
49+
50+
```Properties
51+
# IoTDB 服务地址(格式:IP:Port)
52+
iotdb.session.url=127.0.0.1:6667
53+
# IoTDB 用户名
54+
iotdb.session.username=root
55+
# IoTDB 用户密码
56+
iotdb.session.password=root
57+
# 指定连接的默认模式
58+
iotdb.session.sql-dialect=table
59+
# 指定连接的默认数据库
60+
iotdb.session.database=wind
61+
# 连接池最大连接数
62+
iotdb.session.max-size=10
63+
```
64+
65+
4. 通过 @Autowired 使用目标 Bean,例如
66+
67+
```java
68+
@Autowired
69+
private ITableSessionPool ioTDBSessionPool;
70+
71+
public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException {
72+
ITableSession tableSession = ioTDBSessionPool.getSession();
73+
final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from table1 limit 10");
74+
while (sessionDataSet.hasNext()) {
75+
final RowRecord rowRecord = sessionDataSet.next();
76+
final List<Field> fields = rowRecord.getFields();
77+
for (Field field : fields) {
78+
System.out.print(field.getStringValue());
79+
}
80+
System.out.println();
81+
}
82+
}
83+
```
84+
85+
## 3. 使用示例
86+
87+
详细的使用示例可参考源码 [examples/iotdb-spring-boot-start](https://github.com/apache/iotdb-extras/tree/master/examples/iotdb-spring-boot-start)

0 commit comments

Comments
 (0)