<c3p0-config>
<!--default configuration, if not specified, use this configuration--
<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>
<!--Initialize Pool size--
<property name= "Initialpoolsize" >2</property>
<!--maximum idle time-
<property name= "MaxIdleTime" >30</property>
<!--maximum number of connections--
<property name= "Maxpoolsize" >10</property>
<!--at least several connections--
<property name= "Minpoolsize" >2</property>
<!--How many batch statements can be executed at a time--
<property name= "Maxstatements" >50</property>
</default-config>
<!--named Configuration--
<named-config name= "Hncu" ><!--here is the name of the Setup profile--
<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]]><!--This setting is <! [cdata[...] The output is not parsed--
</property>
<property name= "user" >root</property><!--mysql login name--
<property name= "Password" >1234</property><!--if no password can be set to <property name= "password" ></ Property>-->
<property name= "Acquireincrement" >5</property><!--if the data in the pool is not connected enough, how many times it grows
<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 ());//the user name and password of MySQL can be exported here;
for (int i=0;i<15;i++) {
Connection con=pool.getconnection ();
System.out.println (Con.hashcode ());//This is the address of the output connection.
}
A detailed description of the C3P0 configuration file in the JDBC Connection pool and how to use it in Java