ソースを参照

chore: 删除 TdEngineService 中未使用的 closeQuietly 方法

mqy20260511
humanleft 2週間前
コミット
9313097021
1個のファイルの変更10行の追加21行の削除
  1. 10
    21
      iot-platform/src/main/java/com/iot/platform/service/TdEngineService.java

+ 10
- 21
iot-platform/src/main/java/com/iot/platform/service/TdEngineService.java ファイルの表示

@@ -558,11 +558,11 @@ public class TdEngineService {
558 558
         try (Connection conn = getConnection()) {
559 559
             // 检查超级表是否存在 — 使用 PreparedStatement 防止 SQL 注入
560 560
             String checkStableSql = "SELECT * FROM information_schema.ins_tables WHERE table_name = ? AND db_name = ?";
561
-            try (PreparedStatement pstmt = conn.prepareStatement(checkStableSql)) {
562
-                pstmt.setString(1, superTableName);
563
-                pstmt.setString(2, dbName);
564
-                pstmt.setQueryTimeout(5);
565
-                try (ResultSet rs = pstmt.executeQuery()) {
561
+            try (PreparedStatement pStmt = conn.prepareStatement(checkStableSql)) {
562
+                pStmt.setString(1, superTableName);
563
+                pStmt.setString(2, dbName);
564
+                pStmt.setQueryTimeout(5);
565
+                try (ResultSet rs = pStmt.executeQuery()) {
566 566
                     if (!rs.next()) {
567 567
                         log.info("超级表不存在,创建: {}.{}", dbName, superTableName);
568 568
                         initTableStructure(dbName, superTableName, table);
@@ -574,11 +574,11 @@ public class TdEngineService {
574 574
             // 检查子表是否存在 — 使用 PreparedStatement 防止 SQL 注入
575 575
             String checkTableSql = "SELECT * FROM information_schema.ins_tables " +
576 576
                     "WHERE table_name = ? AND db_name = ? AND table_type = 'CHILD_TABLE'";
577
-            try (PreparedStatement pstmt = conn.prepareStatement(checkTableSql)) {
578
-                pstmt.setString(1, table);
579
-                pstmt.setString(2, dbName);
580
-                pstmt.setQueryTimeout(5);
581
-                try (ResultSet rs = pstmt.executeQuery()) {
577
+            try (PreparedStatement pStmt = conn.prepareStatement(checkTableSql)) {
578
+                pStmt.setString(1, table);
579
+                pStmt.setString(2, dbName);
580
+                pStmt.setQueryTimeout(5);
581
+                try (ResultSet rs = pStmt.executeQuery()) {
582 582
                     if (!rs.next()) {
583 583
                         String tableSql = String.format(
584 584
                                 "CREATE TABLE IF NOT EXISTS %s.%s USING %s.%s TAGS ('%s')",
@@ -616,15 +616,4 @@ public class TdEngineService {
616 616
         }
617 617
     }
618 618
 
619
-    private void closeQuietly(AutoCloseable... resources) {
620
-        for (AutoCloseable resource : resources) {
621
-            if (resource != null) {
622
-                try {
623
-                    resource.close();
624
-                } catch (Exception e) {
625
-                    log.debug("关闭资源时发生异常: {}", e.getMessage());
626
-                }
627
-            }
628
-        }
629
-    }
630 619
 }

読み込み中…
キャンセル
保存