DELL
2024-02-23 7a1e39c59364ef80d68ea36c3e5aa004185077ba
iec61850_forFoShanAES_Model/src/com/iedscout/BTS61850_IEDScout_Task_Thread_SQL.java
@@ -19,15 +19,15 @@
      Sql_Mysql sql = new Sql_Mysql(pool);
      try {
         res = sql.sqlMysqlQuery(sql_str);
         if(!res.next()) {
            sql.sqlMysqlExecute("INSERT INTO  " + Sql_Mysql.Connect_Inf_Table + "(target_ip,target_port,conn_st) VALUES('127.0.0.1',102,0);");
         }else{
         if(res.next()) {
            int count_num = res.getInt("count_num");
            if(count_num > 1) {
               sql.sqlMysqlExecute("DELETE FROM " + Sql_Mysql.Connect_Inf_Table + " WHERE num > 1");
               sql.sqlMysqlExecute("DELETE FROM " + Sql_Mysql.Connect_Inf_Table);
               sql.sqlMysqlExecute("INSERT INTO  " + Sql_Mysql.Connect_Inf_Table + "(num,target_ip,target_port,conn_st) VALUES(1,'127.0.0.1',102,0);");
            }else {
            }else if(count_num == 1){
               sql.sqlMysqlExecute(" UPDATE " + Sql_Mysql.Connect_Inf_Table + " set conn_st = 0;");
            }else {
               sql.sqlMysqlExecute("INSERT INTO  " + Sql_Mysql.Connect_Inf_Table + "(num,target_ip,target_port,conn_st) VALUES(1,'127.0.0.1',102,0);");
            }
         }
      } catch (SQLException e) {
@@ -205,7 +205,33 @@
   }
   public static boolean queryIed_NodeState_TableStopConnect(MysqlConnPool pool) {
      String sql_str = "SELECT * FROM " + Sql_Mysql.Connect_Inf_Table +" where  conn_st = 0;";
      boolean flag = false;
      ResultSet res = null;
      Sql_Mysql sql = new Sql_Mysql(pool);
      try {
         res = sql.sqlMysqlQuery(sql_str);
         if(res.next()) {
            flag = true;
         }
      } catch (SQLException e) {
         sql.logger.error("BTS61850_IEDScout_Task_Thread_SQL.insertIntoIed_NodeState_Table():" + e.toString(), e);
      } finally {
         if(null != res) {
            try {
               res.close();
            } catch (SQLException e) {
               sql.logger.error("BTS61850_IEDScout_Task_Thread_SQL.insertIntoIed_NodeState_Table():" + e.toString(), e);
            }
         }
         sql.close_con();
      }
      return flag;
   }
   public static void main(String[] args) {
      MysqlConnPool pool = new MysqlConnPool("192.168.10.82", 3360, 5);
      System.out.println(queryIed_NodeState_TableStopConnect(pool));;
      
      return false;
   }
}