蓄电池监控管理平台数据库初始化程序
DELL
2025-01-11 d2e2f2b852d5adadcdbb1b247dd7c6ecc13c9da2
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
100
package com.sql;
 
import com.mchange.v2.c3p0.ComboPooledDataSource;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;
 
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
 
public class MysqlConnPool {
    public static final int SQL_Type_MySQL         = 1;    //mysql
    public static final int SQL_Type_HanGao     = 2;    //嫸ß
    
    private ComboPooledDataSource mysql_ds = new ComboPooledDataSource();
    private int mSqlPort = 3360;
    private Logger logger;
 
    public MysqlConnPool(String server_ip, int port, int conncount_max,int sql_type) {
        try {
            logger = LogManager.getLogger(this);
            logger.info("SqlServerType:" + getSqlServerType(sql_type));
            if(SQL_Type_HanGao == sql_type) {
                //嫸ßÊý¾Ý¿â
                initHG(server_ip, port, conncount_max);
            } else {
                //ĬÈÏÁ¬½ÓMySQL
                init(server_ip,port,conncount_max);
            }
        } catch (PropertyVetoException e) {
            e.printStackTrace();
        }
    }
    public MysqlConnPool(String server_ip, int port, int conncount_max) {
        try {
            initHG(server_ip, port, conncount_max);
        } catch (PropertyVetoException e) {
            e.printStackTrace();
        }
    }
 
 
    public void initHG(String server_ip, int port, int conncount_max) throws PropertyVetoException {
        this.mSqlPort = port;
        this.mysql_ds.setDriverClass("com.highgo.jdbc.Driver");
        this.mysql_ds.setJdbcUrl("jdbc:highgo://" + server_ip + ":" + port + "/highgo");
        this.mysql_ds.setUser("sysdba");
//        this.mysql_ds.setPassword("Lmx&8688139");
        this.mysql_ds.setPassword("Fg001@HDW");            //ÐÂÃÜÂë
        this.mysql_ds.setMaxPoolSize(conncount_max);
        this.mysql_ds.setMinPoolSize(2);
        this.mysql_ds.setIdleConnectionTestPeriod(300);
    }
 
    public void init(String server_ip, int port, int conncount_max) throws PropertyVetoException {
        this.mSqlPort = port;
        this.mysql_ds.setDriverClass("com.mysql.jdbc.Driver");
        this.mysql_ds.setJdbcUrl("jdbc:mysql://" + server_ip + ":" + this.mSqlPort);
        this.mysql_ds.setUser("root");
        this.mysql_ds.setPassword("lmx8688139");
        this.mysql_ds.setMaxPoolSize(conncount_max);
        this.mysql_ds.setMinPoolSize(2);
        this.mysql_ds.setIdleConnectionTestPeriod(300);
    }
 
    public String getSqlServerType(int sqlServerType) {
        String sqltypestr = "MySQL";
        switch (sqlServerType) {
        case SQL_Type_MySQL:
            sqltypestr = "MySQL";
            break;
        case SQL_Type_HanGao:
            sqltypestr = "HanGao";
            break;
        default:sqltypestr = "MySQL";
            break;
        }
        return sqltypestr;
    }
    
    public Connection getConn() {
        Connection con = null;
        try {
            con = this.mysql_ds.getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return con;
    }
 
    public int getSqlConnPort() {
        return this.mSqlPort;
    }
}
 
/*
 * Location:
 * C:\Users\LiJun\Desktop\¹«Ë¾¸÷ÖÖÉ豸×ÊÁÏ\9600ÏÔʾģ¿éÏà¹ØÎļþ\ºǫ́³ÌÐò\2018-09-07\BattFBS9600XSP.
 * jar Qualified Name: com.sql.MysqlConnPool JD-Core Version: 0.6.2
 */