C3P0 Connection Pool

Source: Internet
Author: User

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&amp;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:

&lt; < Less than sign
&gt; > Greater than sign
&amp; & And
&apos; Single quotation marks
&quot; " Double quotes

C3P0 Connection Pool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.