DELL
2024-12-16 13b303d0d82e77f7cc7bf1daa7a56d1299ac04d2
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
package com.sql;
 
import com.mchange.v2.c3p0.ComboPooledDataSource;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;
 
public class MysqlConnPool {
    private ComboPooledDataSource mysql_ds = new ComboPooledDataSource();
    private int mSqlPort = 3360;
 
    public MysqlConnPool(String server_ip, int port, int conncount_max) {
        try {
            init(server_ip, port, conncount_max);
        } catch (PropertyVetoException e) {
            e.printStackTrace();
        }
    }
 
    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("Hdw8688139");
        this.mysql_ds.setMaxPoolSize(conncount_max);
        this.mysql_ds.setMinPoolSize(2);
        this.mysql_ds.setIdleConnectionTestPeriod(300);
    }
 
    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
 */