山西太原电源的通信程序【在用】
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.power.alarm;
 
import java.sql.ResultSet;
import java.sql.SQLException;
 
import com.power.mysql.MysqlConnPool;
import com.power.mysql.Sql_Mysql;
 
public class PwrDeviceAlarm_Thread_SQL {
    
    /**
     *     ¶ÁÈ¡ÊÇ·ñÐèÒª¸üеçÔ´¸æ¾¯²ÎÊý
     * @param pool
     * @return
     */
    public static int quereyAlarmThreadParam(MysqlConnPool pool) {
        int thread_en = 0;
        String sql_str = "SELECT * FROM web_site.tb_thread_util WHERE thread_id = 2019003";
        ResultSet res = null;
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            res = sql.sqlMysqlQuery(sql_str);
            if(res.next()) {
                thread_en = res.getInt("thread_en");
            }
        } catch (SQLException e) {
            sql.logger.error(e.toString(), e);
        } finally {
            if(null != res) {
                try {
                    res.close();
                } catch (SQLException e) {
                    sql.logger.error(e.toString(), e);
                }
            }
            sql.close_con();
        }
        return thread_en;
    }
    
    /**
     *     ¶ÁÈ¡ÊÇ·ñÐèÒª¸üеçÔ´¸æ¾¯²ÎÊý
     * @param pool
     * @return
     */
    public static int updateAlarmThreadParam(MysqlConnPool pool,int thread_en) {
        String sql_str = " UPDATE web_site.tb_thread_util" + 
                         " SET thread_en = " + thread_en + 
                         " WHERE thread_id = 2019003";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            sql.logger.error(e.toString(), e);
        } finally {
            sql.close_con();
        }
        return thread_en;
    }
}