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("lmx8688139");
|
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
|
*/
|