package com.testmian.utils;
import java.sql.Connection;
import java.sql.SQLException;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class C3p0Utils {
/**
* @author rolling in the deep
* @version 1.0
*/
//数据库连接池对象
private static ComboPooledDataSource cs=new ComboPooledDataSource();
/**
* 对外提供获取c3p0原始的对象
* @return ComboPooledDataSource
*/
public static ComboPooledDataSource getCom(){
return cs;
}
/**
* 对外提供接口,获取数据库连接对象
* @return Connnection
*/
public static Connection getCon(){
try {
return getCom().getConnection();
} catch (SQLException e) {
//注意异常类的处理细节
throw new RuntimeException(e);
}
}
}
import java.sql.Connection;
import java.sql.SQLException;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class C3p0Utils {
/**
* @author rolling in the deep
* @version 1.0
*/
//数据库连接池对象
private static ComboPooledDataSource cs=new ComboPooledDataSource();
/**
* 对外提供获取c3p0原始的对象
* @return ComboPooledDataSource
*/
public static ComboPooledDataSource getCom(){
return cs;
}
/**
* 对外提供接口,获取数据库连接对象
* @return Connnection
*/
public static Connection getCon(){
try {
return getCom().getConnection();
} catch (SQLException e) {
//注意异常类的处理细节
throw new RuntimeException(e);
}
}
}