c3p0 c3p0.properties

来源:互联网 发布:java逐个读取单词 编辑:程序博客网 时间:2024/05/18 00:10

JdbcUtil

import java.sql.Connection;import java.sql.SQLException;import com.mchange.v2.c3p0.ComboPooledDataSource;public class JdbcUtil {    static String url;    static String user;    static String pwd;    static ComboPooledDataSource cpds;    static {        cpds = new ComboPooledDataSource();    }    /** 获取连接 **/    public static Connection getConn() throws SQLException {        return cpds.getConnection();        // Connection connection = DriverManager.getConnection(url, user, pwd);    }}

c3p0.properties

c3p0.driverClass = com.mysql.jdbc.Driverc3p0.jdbcUrl = jdbc:mysql://localhost:3306/webexamc3p0.user = rootc3p0.password =c3p0.maxPoolSize = 20c3p0.minPoolSize = 3c3p0.maxStatements = 30c3p0.maxIdleTime = 150