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.Driver
c3p0.jdbcUrl = jdbc:mysql://localhost:3306/webexam
c3p0.user = root
c3p0.password =
c3p0.maxPoolSize = 20
c3p0.minPoolSize = 3
c3p0.maxStatements = 30
c3p0.maxIdleTime = 150