<c3p0-config>
<!-- 默认配置,如果没有指定则使用这个配置 -->
<default-config>
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">
<![CDATA[jdbc:mysql://127.0.0.1:3306/hncu?useUnicode=true&characterEncoding=UTF-8]]>
</property>
<property name="user">root</property>
<property name="password">1234</property>
<!-- 初始化池大小 -->
<property name="initialPoolSize">2</property>
<!-- 最大空闲时间 -->
<property name="maxIdleTime">30</property>
<!-- 最多有多少个连接 -->
<property name="maxPoolSize">10</property>
<!-- 最少几个连接 -->
<property name="minPoolSize">2</property>
<!-- 每次最多可以执行多少个批处理语句 -->
<property name="maxStatements">50</property>
</default-config>
<!-- 命名的配置 -->
<named-config name="hncu"><!--这里是设置配置文件的名字-->
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">
<![CDATA[jdbc:mysql://127.0.0.1:3306/hncu?useUnicode=true&characterEncoding=UTF-8]]><!--这个设置是<![CDATA[...]]是原样输出不会进行解析-->
</property>
<property name="user">root</property><!--mysql的登陆名-->
<property name="password">1234</property><!--如果没密码就可以设置成<property name="password"></property>-->
<property name="acquireIncrement">5</property><!-- 如果池中数据连接不够时一次增长多少个 -->
<property name="initialPoolSize">10</property>
<property name="minPoolSize">5</property>
<property name="maxPoolSize">15</property>
<property name="maxStatements">0</property>
<property name="maxStatementsPerConnection">5</property> <!-- he‘s important, but there‘s only one of him -->
</named-config>
</c3p0-config>
-------------------------------------------------------------------------------------------------------------------------------------------
import com.mchange.v2.c3p0.ComboPooledDataSource;
ComboPooledDataSource pool=new ComboPooledDataSource();
System.out.println(pool.getProperties());//这里可以输出mysql的用户名和密码;
for(int i=0;i<15;i++){
Connection con=pool.getConnection();
System.out.println(con.hashCode());//这里是输出连接的地址。
}