C3P0數據源
一、拷貝jar包
在c3p0發行包的lib目錄中
c3p0-0.9.1.2.jar
c3p0-0.9.1.2-jdk1.3.jar
c3p0-oracle-thin-extras-0.9.1.2.jar(oracle)
二、在類路徑下建立一個名爲c3p0-config.xml的配置文件
<c3p0-config>
<named-config name="day14">
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql:///day14</property>
<property name="user">root</property>
<property name="password">sorry</property>
<property name="acquireIncrement">10</property>
<property name="initialPoolSize">30</property>
<property name="minPoolSize">5</property>
<property name="maxPoolSize">40</property>
<property name="maxStatements">1000</property>
<property name="maxStatementsPerConnection">100</property>
</named-config>
</c3p0-config>
三、創建一個工具類,根據配置文件獲取數據源
private static ComboPooledDataSource ds = new ComboPooledDataSource ("day14");
public static Connection getConn() throws SQLException{
return ds.getConnection();
}mysql