You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This demo shows how to use iotdb-spring-boot-starter
Version usage
IoTDB: 2.0.3
iotdb-spring-boot-starter: 2.0.3
1. Install IoTDB
please refer to [https://iotdb.apache.org/#/Download](https://iotdb.apache.org/#/Download)
2. Startup IoTDB
please refer to [Quick Start](http://iotdb.apache.org/UserGuide/Master/Get%20Started/QuickStart.html)
Then we need to create a database 'wind' by cli in table model
```
create database wind;
use wind;
```
Then we need to create a database 'table'
```
CREATE TABLE table1 (
time TIMESTAMP TIME,
region STRING TAG,
plant_id STRING TAG,
device_id STRING TAG,
model_id STRING ATTRIBUTE,
maintenance STRING ATTRIBUTE,
temperature FLOAT FIELD,
humidity FLOAT FIELD,
status Boolean FIELD,
arrival_time TIMESTAMP FIELD
) WITH (TTL=31536000000);
```
You can use the target Bean in your Project,like:
```
@Autowired
private ITableSessionPool ioTDBSessionPool;
@Autowired
private SessionPool sessionPool;
public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException {
ITableSession tableSession = ioTDBSessionPool.getSession();
final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from power_data_set limit 10");
while (sessionDataSet.hasNext()) {
final RowRecord rowRecord = sessionDataSet.next();
final List<Field> fields = rowRecord.getFields();
for (Field field : fields) {
System.out.print(field.getStringValue());
}
System.out.println();
}
}
public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException {
final SessionDataSetWrapper sessionDataSetWrapper = sessionPool.executeQueryStatement("show databases");
while (sessionDataSetWrapper.hasNext()) {
final RowRecord rowRecord = sessionDataSetWrapper.next();
final List<Field> fields = rowRecord.getFields();
for (Field field : fields) {
System.out.print(field.getStringValue());
}
System.out.println();
}
}
```