1 C3P0简介
C3P0也是开源免费的连接池!C3P0被很多人看好!
2 C3P0的使用
package com.cug.c3p0;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;
import org.junit.Test;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class C3P0Demo {
@Test
public void fun1() throws PropertyVetoException, SQLException{
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setUser("root");
dataSource.setPassword("123");
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/mydb1");
dataSource.setDriverClass("com.mysql.jdbc.Driver");
dataSource.setMaxPoolSize(30);
dataSource.setMinPoolSize(10);
dataSource.setInitialPoolSize(10);
dataSource.setMaxIdleTime(3000);
dataSource.setAcquireIncrement(5);