最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Springboot整合IoTB的實(shí)現(xiàn)示例

 更新時(shí)間:2025年12月23日 10:40:47   作者:moxiaoran5753  
本文主要介紹了Springboot整合IoTB的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

一、引入依賴

 <!--引入iotdb session依賴-->
<dependency>
	<groupId>org.apache.iotdb</groupId>
	<artifactId>iotdb-session</artifactId>
	<version>1.3.2</version>
</dependency>

二、配置IotDB連接

iotdb:
  username: root
  password: root
  ip: 192.168.56.10
  port: 6667
  #批量操作數(shù)量
  maxSize: 200

三、創(chuàng)建配置類

import lombok.extern.slf4j.Slf4j;
import org.apache.iotdb.session.pool.SessionPool;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@Slf4j
public class IotDBSessionConf {

    @Value("${iotdb.username}")
    private String username;

    @Value("${iotdb.password}")
    private String password;

    @Value("${iotdb.ip}")
    private String ip;

    @Value("${iotdb.port}")
    private int port;

    @Value("${iotdb.maxSize}")
    private int maxSize;

    //Session線程池
    private static SessionPool pool;

    @Bean
    public SessionPool initSessionPool() {

        if(pool==null) {

            log.info(">>>>>SessionPool初始化....");

            pool =
            new SessionPool.Builder()
                    .user(username)
                    .password(password)
                    .host(ip)
                    .port(port)
                    .maxSize(maxSize)
                    .build();
        }


        return pool;

    }
}

四、創(chuàng)建service和實(shí)現(xiàn)類

@Service
@RequiredArgsConstructor
public class IoTDBServiceImpl implements IoTDBService {

    private final IotDBSessionConf conf;

    @Override
    public SessionDataSetWrapper executeQueryStatement(String sql) {
        SessionPool sessionPool = conf.initSessionPool();
        SessionDataSetWrapper wrapper = null;
        try {
            wrapper = sessionPool.executeQueryStatement(sql);
        } catch (IoTDBConnectionException e) {
            throw new RuntimeException(e);
        } catch (StatementExecutionException e) {
            throw new RuntimeException(e);
        }
        return wrapper;
    }

    @Override
    public SessionDataSetWrapper executeRawDataQuery(List<String> path, long startTime, long endTime, long timeOut) {
        SessionPool sessionPool = conf.initSessionPool();
        SessionDataSetWrapper wrapper = null;
        try {
            wrapper = sessionPool.executeRawDataQuery(path, startTime, endTime, timeOut);
        } catch (IoTDBConnectionException e) {
            throw new RuntimeException(e);
        } catch (StatementExecutionException e) {
            throw new RuntimeException(e);
        }
        return wrapper;
    }
}

五、創(chuàng)建工具類

@RequiredArgsConstructor
public class IoTDBUtils {

    private final IoTDBService iotDBService;

    /**
     * 根據(jù)自定義SQL語句執(zhí)行查詢
     * @param sql
     * @return
     */
    SessionDataSetWrapper executeQueryStatement(String sql) {
        return iotDBService.executeQueryStatement(sql);
    }

    /**
     * 根據(jù)時(shí)間區(qū)間執(zhí)行查詢數(shù)據(jù)
     * @param paths 時(shí)間序列
     * @param startTime 開始時(shí)間戳(包含)
     * @param endTime 結(jié)束時(shí)間戳(不包含)
     * @param timeOut 超時(shí)時(shí)間
     * @return
     */
    SessionDataSetWrapper executeRawDataQuery(List<String> paths, long startTime, long endTime, long timeOut){
        return iotDBService.executeRawDataQuery(paths, startTime, endTime, timeOut);
    }
}

單元測試

@SpringBootTest(classes = IotDBSessionConfTest.class)
public class IotDBSessionConfTest {

    // 測試連接
    @Test
    public void testInitSessionPool() {
        IotDBSessionConf conf = new IotDBSessionConf();
        SessionPool sessionPool = conf.initSessionPool();
        System.out.println(sessionPool.getVersion());
    }
}

到此這篇關(guān)于Springboot整合IoTB的實(shí)現(xiàn)示例的文章就介紹到這了,更多相關(guān)Springboot整合IoTB內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • springMvc請求的跳轉(zhuǎn)和傳值的方法

    springMvc請求的跳轉(zhuǎn)和傳值的方法

    本篇文章主要介紹了springMvc請求的跳轉(zhuǎn)和傳值的方法,這里整理了幾種跳轉(zhuǎn)方式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-02-02
  • Java實(shí)現(xiàn)獲取圖片和視頻文件的Exif信息

    Java實(shí)現(xiàn)獲取圖片和視頻文件的Exif信息

    這篇文章將重點(diǎn)為大家介紹一下如何使用Java編程語言結(jié)合metadata-extractor去自動(dòng)獲取全景圖片的Exif信息,獲取照片的拍攝坐標(biāo)信息,感興趣的可以了解一下
    2022-11-11
  • 詳解Mybatis中javaType和ofType的區(qū)別

    詳解Mybatis中javaType和ofType的區(qū)別

    本文主要介紹了詳解Mybatis中javaType和ofType的區(qū)別,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-05-05
  • SpringBoot3.X 整合 MinIO 存儲原生方案

    SpringBoot3.X 整合 MinIO 存儲原生方案

    本文詳細(xì)介紹了SpringBoot3.X整合MinIO的原生方案,從環(huán)境搭建到核心功能實(shí)現(xiàn),涵蓋了文件上傳、下載、刪除等常用操作,并補(bǔ)充了異常處理、參數(shù)校驗(yàn)、安全實(shí)踐等內(nèi)容,感興趣的朋友一起看看吧
    2025-07-07
  • 深入解析Java的Spring框架中的混合事務(wù)與bean的區(qū)分

    深入解析Java的Spring框架中的混合事務(wù)與bean的區(qū)分

    這篇文章主要介紹了Java的Spring框架中的混合事務(wù)與bean的區(qū)分,Spring是Java的SSH三大web開發(fā)框架之一,需要的朋友可以參考下
    2016-01-01
  • Java Apache POI實(shí)現(xiàn)導(dǎo)出Excel的實(shí)戰(zhàn)指南

    Java Apache POI實(shí)現(xiàn)導(dǎo)出Excel的實(shí)戰(zhàn)指南

    在企業(yè)級開發(fā)中,Excel 數(shù)據(jù)導(dǎo)出是高頻需求,本文基于 Apache POI 實(shí)現(xiàn)災(zāi)情速報(bào)員數(shù)據(jù) Excel 導(dǎo)出功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下
    2026-04-04
  • java自動(dòng)生成接口文檔完整代碼示例

    java自動(dòng)生成接口文檔完整代碼示例

    在軟件開發(fā)中,編寫接口文檔是一項(xiàng)必要但繁瑣的任務(wù),為了簡化這一過程,可以通過使用Swagger2和Swagger-UI來自動(dòng)生成接口文檔,這篇文章主要介紹了java自動(dòng)生成接口文檔的相關(guān)資料,需要的朋友可以參考下
    2021-07-07
  • java 如何將圖片按照原尺寸比例存入word中

    java 如何將圖片按照原尺寸比例存入word中

    這篇文章主要介紹了java 如何將圖片按照原尺寸比例存入word中的操作,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-07-07
  • 在SpringBoot中通過jasypt進(jìn)行加密解密的方法

    在SpringBoot中通過jasypt進(jìn)行加密解密的方法

    今天小編就為大家分享一篇關(guān)于在SpringBoot中通過jasypt進(jìn)行加密解密的方法,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • Spring?Boot最經(jīng)典的20道面試題你都會了嗎

    Spring?Boot最經(jīng)典的20道面試題你都會了嗎

    Spring Boot是現(xiàn)代化的Java應(yīng)用程序開發(fā)框架,具有高度的靈活性和可擴(kuò)展性,下面這篇文章主要給大家介紹了關(guān)于Spring?Boot最經(jīng)典的20道面試題,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-06-06

最新評論

类乌齐县| 本溪| 英吉沙县| 潜山县| 文山县| 桐梓县| 普兰县| 泸定县| 郁南县| 宝鸡市| 梧州市| 兴国县| 怀安县| 澳门| 新宾| 塘沽区| 宁阳县| 泰和县| 龙游县| 申扎县| 大兴区| 阿尔山市| 惠安县| 于田县| 宁晋县| 邢台县| 武城县| 榆林市| 三明市| 冷水江市| 朔州市| 田东县| 乃东县| 福清市| 怀来县| 新闻| 天镇县| 洞头县| 于田县| 尚志市| 砀山县|