C3P0 is an open source JDBC connection pool that implements the data source and Jndi bindings, and supports the standard extensions of the JDBC3 specification and JDBC2. The open source projects that currently use it are hibernate,spring, etc.
To configure a database connection pool using C3P0
configuration file: C3p0-config.xml<C3p0-config><Named-configname= "DbInfo"><!-Configure user name password, connection, driver? <property name= "User">Admin</ Property>< Propertyname= "Password">Admin</ Property>< Propertyname= "Jdbcurl">Jdbc:mysql:///blog</ Property>< Propertyname= "Driverclass">Com.mysql.jdbc.Driver</ Property><!--database connection Pool How many connections to the database server at a time -< Propertyname= "Acquireincrement">5</ Property><!--Initialize the number of connections -< Propertyname= "Initialpoolsize">5</ Property><!--minimum number of connections -< Propertyname= "Minpoolsize">5</ Property><!--Maximum number of connections -< Propertyname= "Maxpoolsize">10</ Property><!--The maximum number of statement that a database connection pool can maintain -< Propertyname= "Maxstatements">20</ Property><!--How many statement can be created per database connection -< Propertyname= "Maxstatementsperconnection">5</ Property></Named-config></C3p0-config>
// Com.mchange.v2.c3p0.ComboPooledDataSource New combopooleddatasource ("dbInfo"= Datasource.getconnection ();
If the reference to entity "characterencoding" must end with the '; ' delimiter such an error occurs:
Reason:
There was a problem when the data source configuration was added with the Encoding conversion format:
The reference to entity "characterencoding" must end with the '; ' delimiter
This error is the problem with setting the URL of the data source link in the configuration file XML
Originally:
Jdbc:mysql://localhost:3306/dbname?useunicode=true&characterencoding=utf-8
After modification:
Jdbc:mysql://localhost:3306/dbname?useunicode=true&characterencoding=utf-8
This is probably determined by the encoding rules in the XML file to be transformed. The following types of characters are escaped in the XML file:
| < |
< |
Less than sign |
| > |
> |
Greater than sign |
| & |
& |
And |
| ' |
‘ |
Single quotation marks |
| " |
" |
Double quotes |
C3P0 Connection Pool