JDBCUtils
作者:互联网
封装JDBCUtils工具类
package com.offcn.util;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import java.sql.Connection;
import java.sql.SQLException;
/**
* 负责管理数据库连接的
* 1.封装连接池对象的创建过程
* 2.封装从连接池中获取数据库连接对象的过程
*/
public class JdbcUtils {
private static ComboPooledDataSource dataSource;
static{
dataSource = new ComboPooledDataSource();
}
public static Connection getConnection(){
try {
return dataSource.getConnection();
} catch (SQLException throwables) {
throwables.printStackTrace();
return null;
}
}
}
标签:JDBCUtils,封装,getConnection,static,ComboPooledDataSource,import,dataSource 来源: https://www.cnblogs.com/conglingkaishi/p/15232261.html