C3P0如何使用?
我现在有个C3P0连接池的代码。。。是以前前辈留下的。。。现在我不会使用,今天放出来就CSDN的大哥帮忙看看如何在BEAN 和JSP里调用!??
package C3P0;
import java.sql.Connection;
import
java.sql.SQLException;
import java.beans.PropertyVetoException;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class DBPool{
private static DBPool dbPool;
private ComboPooledDataSource dataSource;
static {
dbPool=new DBPool();
}
public DBPool(){
try {
dataSource=new ComboPooledDataSource();
dataSource.setUser( "id ");
dataSource.setPassword( "pw ");
dataSource.setJdbcUrl( "jdbc:mysql://127.0.0.1:3306/test?
autoReconnect=true&useUnicode=true&characterEncoding=GB2312 ");
dataSource.setDriverClass( "com.mysql.jdbc.Driver ");
dataSource.setInitialPoolSize(2);
dataSource.setMinPoolSize(1);
dataSource.setMaxPoolSize(10);
dataSource.setMaxStatements(50);
dataSource.setMaxIdleTime(60);
} catch (PropertyVetoException e) {
throw new
RuntimeException(e);
}
}
public final static DBPool getInstance(){
return dbPool;
}
public final Connection getConnection() {
try {
return dataSource.getConnection();
} catch (
SQLException e) {