1 导入jar
c3p0-0.9.1.2.jar
2 配置文件放src路径下面
c3p0-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<default-config>
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql://localhost:3306/zhipan</property>
<property name="user">root</property>
<property name="password">1111</property>
<property name="initialPoolSize">10</property>
<property name="maxIdleTime">30</property>
<property name="maxPoolSize">100</property>
<property name="minPoolSize">10</property>
</default-config>
</c3p0-config>
3 得到数据源以及数据库连接
ComboPooledDataSource cpds = new ComboPooledDataSource();
Connection connection=cpds.getConnection();
4测试