Java API
IoTDB provides a connection pool (SessionPool) for native APIs. When using the APIs, you only need to specify the pool size to obtain connections from the pool. If you cannot get a connection in 60 seconds, a warning log will be printed, but the program continues to wait.
When a connection is used, it automatically returns to the pool and waits to be used next time. When a connection is damaged, it is deleted from the pool and a new connection is created to perform user operations again.
For query operations:
- When SessionPool is used for query, the result set is SessionDataSetWrapper, the encapsulation class of SessionDataSet.
- If a query result set is not traversed and you do not want to continue traversing, you need to call closeResultSet to release the connection.
- If an exception is reported when you traverse a query result set, you need to call closeResultSet to release the connection.
- You can call the getColumnNames() method of SessionDataSetWrapper to obtain the column names in the result set.
Method |
Description |
---|---|
|
Initializes a session. |
Session.open() |
Opens a session. |
Session.close() |
Closes a session. |
void setStorageGroup(String storageGroupId) |
Sets a storage group. |
|
Deletes one or more storage groups. |
|
Creates one or more time series. |
|
Deletes one or more time series. |
|
Deletes the data of one or more time series before or at a specific time point. |
void insertRecord(String deviceId, long time, List<String> measurements, List<String> values) |
Inserts a record, which contains the data of multiple measurement points of a device at a timestamp. Servers need to perform type inference, which may take extra time. |
void insertTablet(Tablet tablet) |
Inserts a tablet, which contains multiple rows of non-empty data blocks. The columns in each row are the same. |
void insertTablets(Map<String, Tablet> tablet) |
Inserts multiple tablets. |
void insertRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<String>> valuesList) |
Inserts multiple records. Servers need to perform type inference, which may take extra time. |
void insertRecord(String deviceId, long time, List<String> measurements, List<TSDataType> types, List<Object> values) |
Inserts a record, which contains the data of multiple measurement points of a device at a timestamp. With the data type information, servers do not need to perform type inference, improving the performance. |
void insertRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList) |
Inserts multiple records. With the data type information, servers do not need to perform type inference, improving the performance. |
submitApplication(SubmitApplicationRequest request) |
Used by the client to submit a new application to ResourceManager. |
void insertRecordsOfOneDevice(String deviceId, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList) |
Inserts multiple records of the same device. |
SessionDataSet executeRawDataQuery(List<String> paths, long startTime, long endTime) |
Queries raw data. The interval includes the start time but does not include the end time. |
SessionDataSet executeQueryStatement(String sql) |
Executes query statements. |
void executeNonQueryStatement(String sql) |
Executes non-query statements. |
Method |
Description |
---|---|
|
Tests testInsertRecords. A response is returned immediately after data is transmitted to the server. No data is written. |
|
Tests insertRecord. A response is returned immediately after data is transmitted to the server. No data is written. |
void testInsertTablet(Tablet tablet) |
Tests insertTablet. A response is returned immediately after data is transmitted to the server. No data is written. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot