Browse Source

chore(P2): 替换mysql驱动,移除emoji统一日志格式

- mysql-connector-java → mysql-connector-j 8.0.33
- TDengineService: 移除9处emoji(✅❌⚠️)
- 统一使用SLF4J {}占位符,无字符串拼接
mqy20260511
humanleft 4 days ago
parent
commit
5cbb11d169

+ 3
- 2
iot-platform/pom.xml View File

65
 
65
 
66
         <!-- Mysql驱动 -->
66
         <!-- Mysql驱动 -->
67
         <dependency>
67
         <dependency>
68
-            <groupId>mysql</groupId>
69
-            <artifactId>mysql-connector-java</artifactId>
68
+            <groupId>com.mysql</groupId>
69
+            <artifactId>mysql-connector-j</artifactId>
70
+            <version>8.0.33</version>
70
         </dependency>
71
         </dependency>
71
 
72
 
72
         <!-- TDengine JDBC -->
73
         <!-- TDengine JDBC -->

+ 8
- 8
iot-platform/src/main/java/com/iot/platform/service/TDengineService.java View File

61
             config.setConnectionTestQuery("SELECT NOW()");
61
             config.setConnectionTestQuery("SELECT NOW()");
62
             config.setValidationTimeout(3000);
62
             config.setValidationTimeout(3000);
63
             this.dataSource = new HikariDataSource(config);
63
             this.dataSource = new HikariDataSource(config);
64
-            log.info("TDengine 连接池初始化完成");
64
+            log.info("TDengine 连接池初始化完成");
65
         } catch (Exception e) {
65
         } catch (Exception e) {
66
-            log.warn("⚠️ TDengine 连接池初始化失败: {}", e.getMessage());
66
+            log.warn("TDengine 连接池初始化失败: {}", e.getMessage());
67
             this.dataSource = null;
67
             this.dataSource = null;
68
         }
68
         }
69
         dataSourceInitialized = true;
69
         dataSourceInitialized = true;
205
             return true;
205
             return true;
206
 
206
 
207
         } catch (SQLException e) {
207
         } catch (SQLException e) {
208
-            log.error("表结构初始化失败: {}.{} | {}", dbName, table, e.getMessage());
208
+            log.error("表结构初始化失败: {}.{} | {}", dbName, table, e.getMessage());
209
             return false;
209
             return false;
210
         } finally {
210
         } finally {
211
             if (stmt != null) try { stmt.close(); } catch (SQLException ignored) {}
211
             if (stmt != null) try { stmt.close(); } catch (SQLException ignored) {}
238
             }
238
             }
239
         }
239
         }
240
 
240
 
241
-        log.info("批量写入成功: {} | 条数: {}", table, dataList.size());
241
+        log.info("批量写入成功: {} | 条数: {}", table, dataList.size());
242
         return true;
242
         return true;
243
     }
243
     }
244
 
244
 
282
         } catch (SQLException e) {
282
         } catch (SQLException e) {
283
             // 表不存在时尝试重建表后重试
283
             // 表不存在时尝试重建表后重试
284
             if (e.getMessage().contains("Table does not exist")) {
284
             if (e.getMessage().contains("Table does not exist")) {
285
-                log.warn("⚠️ 表不存在,重建表: {}", table);
285
+                log.warn("表不存在,重建表: {}", table);
286
                 initTableStructure(dbName, supertablename, table, Collections.emptySet());
286
                 initTableStructure(dbName, supertablename, table, Collections.emptySet());
287
                 return insertBatchRetry(dbName, supertablename, table, dataList);
287
                 return insertBatchRetry(dbName, supertablename, table, dataList);
288
             }
288
             }
289
-            log.error("批量写入 SQL 失败: {} | 错误: {}", table, e.getMessage());
289
+            log.error("批量写入 SQL 失败: {} | 错误: {}", table, e.getMessage());
290
             return false;
290
             return false;
291
         } finally {
291
         } finally {
292
             if (stmt != null) try { stmt.close(); } catch (SQLException ignored) {}
292
             if (stmt != null) try { stmt.close(); } catch (SQLException ignored) {}
326
             stmt.executeUpdate(finalSql);
326
             stmt.executeUpdate(finalSql);
327
             return true;
327
             return true;
328
         } catch (SQLException e) {
328
         } catch (SQLException e) {
329
-            log.error("重试插入失败: {} | 错误: {}", table, e.getMessage());
329
+            log.error("重试插入失败: {} | 错误: {}", table, e.getMessage());
330
             return false;
330
             return false;
331
         } finally {
331
         } finally {
332
             if (stmt != null) try { stmt.close(); } catch (SQLException ignored) {}
332
             if (stmt != null) try { stmt.close(); } catch (SQLException ignored) {}
381
                         escapeValue(supertablename)
381
                         escapeValue(supertablename)
382
                 );
382
                 );
383
                 stmt.executeUpdate(tableSql);
383
                 stmt.executeUpdate(tableSql);
384
-                log.info("子表创建成功: {}", table);
384
+                log.info("子表创建成功: {}", table);
385
             }
385
             }
386
         } catch (SQLException e) {
386
         } catch (SQLException e) {
387
             log.warn("检查表存在性失败,继续尝试插入: {}", e.getMessage());
387
             log.warn("检查表存在性失败,继续尝试插入: {}", e.getMessage());

Loading…
Cancel
Save