package com.itheima.c_c3p0; import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; import com.mchange.v2.c3p0.ComboPooledDataSource; public class C3P0Utils { //提供连接池 private static DataSource dataSource = new ComboPooledDataSource("day17_config"); public static Connection getConnection() throws SQLException{ //从连接池中获得的 return dataSource.getConnection(); } /** * 数据源,连接池 * @return */ public static DataSource getDataSource(){ return dataSource; } }
C3P0数据库连接池-方式2读取配置文件的方式,布布扣,bubuko.com
原文地址:http://blog.csdn.net/hymking/article/details/29394207