whyclj
2020-08-11 abad654e79db166bb5eb30a0809b145b1031d126
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
 
import com.base.Com;
import com.config.AppConfig;
import com.config.AppParam;
import com.sql.MysqlConnPool;
 
public class main_WaterSystem_MonitorServer {
    /**************************************************************************/
    /**************************************************************************/
    /**************************************************************************/
    /**************************************************************************/
    /**************************************************************************/
    public final static boolean app_debug = false;
    
    public final static double m_VersionNum = 1.102;
    public final static String m_Version = "Welcome To Use main_MonitorServer_Motor V" 
                                            + m_VersionNum ;
    /**************************************************************************/
    
    
    /**************************************************************************/
    public static final int MysqlServer_Port = 3360;
    
    private static AppConfig m_AppConfig;
    
    private static MysqlConnPool GB_MysqlConnPool;
    public static AppParam GB_App_Param;
    
    
     /*********************************************************************************************/
    /*********************************************************************************************/
    public static void main(String[] args) {
        String ver = m_Version;
        
        System.out.println("main_MonitorServer_Motor Server Started At DateTime: " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
        //´´½¨config.xmlÎļþ
        m_AppConfig = new AppConfig();
        
        System.out.println("SQLserver IP£º" + m_AppConfig.getMysqlServerIp() + ", port: "+MysqlServer_Port);
        //³õʼ»¯Á¬½Ó³ØÖеĸ÷ÖÖ²ÎÊýÐÅÏ¢
        GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, 
                                                100);
        
        //´´½¨tb_app_param±í,²¢ÇÒÉèÖñíÖеÄÊý¾Ý
        GB_App_Param = new AppParam(GB_MysqlConnPool);
        
        checkingMySQLServerStart();                //¼ì²âÊý¾Ý¿â·þÎñÊÇ·ñÆô¶¯
        /*********************************************************************************/
        /*********************************************************************************/
        
        
        
        while(true) {
            try {        
                Thread.sleep(5000);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        /*********************************************************************************/
    }
    
    public static void checkingMySQLServerStart(){
        int MysqlServer_Port = 3360;
        System.out.println("IP£º"+m_AppConfig.getMysqlServerIp()+"port"+MysqlServer_Port);            
        //³õʼ»¯Á¬½Ó³ØÖеĸ÷ÖÖ²ÎÊýÐÅÏ¢        m_AppConfig.getMysqlServerIp()
        GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, 5);
        while(true){
            Connection conn = null;
            try {
                System.out.println(" ¿ªÊ¼¼ì²âÊý¾Ý¿âÁ¬½Ó "+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
                conn =  GB_MysqlConnPool.getConn();
                if(conn != null){
                    System.out.println("¼ì²âÊý¾Ý¿âÁ¬½Ó³É¹¦");
                    break;
                }
            } catch (Exception e) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
                System.out.println(" MySQL_FBSDEV not Start ... ");
            } finally {
                if(conn != null) {
                    try {
                        conn.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}