<p><iframe name="ifd" src="https://mnifdv.cn/resource/cnblogs/iot_terminal_management" frameborder="0" scrolling="auto" width="100%" height="1500"></iframe></p>
说明
这节是java使用Druid连接池查询MySQL数据库数据,并通过MQTT发送
测试
1,使用IntelliJ IDEA 打开这节的工程
2,源码需要使用JDK1.8及其以上版本
如果版本小于1.8则需要安装(只需要安装,不需要配置环境变量)
安装完以后不需要配置环境变量,只需要在软件中设置JDK路径
3,先启动看下效果(默认连接我的数据库和MQTT)
4,打开MQTT调试助手
发布的主题:historical/request/863488051205014
订阅的主题:historical/receive/863488051205014
发送的消息:{"data":"humiture","start_time":"2022-07-30 00:00:00","stop_time":"2022-07-30 22:48:00"}
{"code":"OK","data":[{"data_time":"2022-07-30 17:07:41","temperature":255.0,"humidity":255.0}, {"data_time":"2022-07-30 22:44:43","temperature":255.0,"humidity":255.0}, {"data_time":"2022-07-30 22:44:46","temperature":255.0,"humidity":255.0}, {"data_time":"2022-07-30 22:44:48","temperature":255.0,"humidity":255.0}, {"data_time":"2022-07-30 22:44:50","temperature":255.0,"humidity":255.0}, {"data_time":"2022-07-30 22:44:52","temperature":255.0,"humidity":255.0}, {"data_time":"2022-07-30 22:44:54","temperature":255.0,"humidity":255.0}, {"data_time":"2022-07-30 22:44:57","temperature":255.0,"humidity":255.0}, {"data_time":"2022-07-30 22:44:59","temperature":255.0,"humidity":255.0}, {"data_time":"2022-07-30 22:45:01","temperature":255.0,"humidity":255.0}], "client_id":"863488051205014"}
5,返回的数据是提供的测试数据库里面的数据