1.引入C3P0(选择了0.9.2.1)
2.添加c3p0-config.xml资源文件
3、代码实现
public class DBUtils { private static DataSource dataSourcec3p0; static { try { dataSourcec3p0 = new ComboPooledDataSource("shoppingc3p0"); } catch (Exception e) { e.printStackTrace(); } } public static Connection getConnectionc3p0() throws IOException,SQLException { // 建立连接 Connection connection = dataSourcec3p0.getConnection(); return connection; } }