C3P0 Specific configuration instructions (Com.mchange.v2.c3p0.ComboPooledDataSource)

Source: Internet
Author: User

C3P0 It is an open source JDBC connection pool, which is advertised by the Lib folder along with Hibernate and contains statement objects for the connection and datasources pools that implement the JDBC3 and JDBC2 extension specification descriptions.

C3p0.acquireincrement=3c3p0.initialpoolsize=3c3p0.idleconnectiontestperiod=900c3p0.minpoolsize= 2c3p0.maxpoolsize=50c3p0.maxstatements=100c3p0.numhelperthreads=10c3p0.maxidletime=600
 <property name=" Acquireincrement "><value>${c3p0.acquireincrement}</value></property ><property name= "Initialpoolsize" ><value>${c3p0.initialPoolSize}</value></property> <property name= "Minpoolsize" ><value>${c3p0.minpoolsize}</value></property><property Name= "Maxpoolsize" ><value>${c3p0.maxpoolsize}</value></property><property name= " MaxIdleTime "><value>${c3p0.maxidletime}</value></property><property name=" Idleconnectiontestperiod "><value>${c3p0.idleConnectionTestPeriod}</value></property>< Property Name= "Maxstatements" ><value>${c3p0.maxstatements}</value></property><property Name= "Numhelperthreads" ><VALUE>${C3P0.NUMHELPERTHREADS}</VALUE></PROPERTY> 


The following is a detailed description of the configuration:

  <c3p0-config>
<default-config>
<!--c3p0 the number of connections fetched at the same time when the connection in the connection pool is exhausted.

Default:3--

<property name= "Acquireincrement" >3</property>


<!--defines the number of times to try repeatedly after a new connection has failed to get from the database.

Default:30--

<property name= "Acquireretryattempts" >30</property>


<!--the interval between two connections, in milliseconds. default:1000--

<property name= "Acquireretrydelay" >1000</property>


<!--All uncommitted actions are rolled back by default when the connection is closed. Default:false--

<property name= "Autocommitonclose" >false</property>


<!--C3P0 will build a blank table named Test. and use its own query statement to test.

Assuming that the parameter is defined, then the attribute preferredtestquery will be ignored. You can't do anything on this test sheet, it will only be used by C3P0 testing. Default:null-->

<property name= "Automatictesttable" >Test</property>


<!--getting a connection failure will cause the thread to wait for the connection pool to get the connection to throw an exception. However, the data source is still valid for retention. and continue trying to get the connection the next time you call Getconnection ().

If set to True, the data source will declare broken and permanently shut down after attempting to acquire a connection failure.

Default:false-->

<property name= "Breakafteracquirefailure" >false</property>


<!--the time when the client calls getconnection () after the connection pool is exhausted and waits for a new connection.

SqlException will be thrown after the timeout, and if set to 0, wait indefinitely.

Unit milliseconds. Efault:0--

<property name= "Checkouttimeout" >100</property>


<!--test the connection by implementing a class of Connectiontester or Queryconnectiontester. The class name needs to be set to the full path.

Default:com.mchange.v2.c3p0.impl.defaultconnectiontester-->

<property name= "Connectiontesterclassname" ></property>


<!--Specify the path to the C3P0 libraries, assuming (usually so) that there is no need to set it locally, and default null can
Default:null-->

<property name= "Factoryclasslocation" >null</property>


<!--strongly disrecommended. Setting this to true may leads to subtle and bizarre bugs. The author strongly recommends not to use a property--

<property name= "Forceignoreunresolvedtransactions" >false</property>


<!--Check the spare connections in all connection pools every 60 seconds.

Default:0--

<property name= "Idleconnectiontestperiod" >60</property>


<!--get three connections when initializing, the value should be between Minpoolsize and Maxpoolsize. Default:3--

<property name= "Initialpoolsize" >3</property>


<!--maximum spare time, unused in 60 seconds the connection is discarded.

If 0, it will never be discarded. Default:0--

<property name= "MaxIdleTime" >60</property>


<!--The maximum number of connections that are kept in the connection pool. Default:15--

<property name= "Maxpoolsize" >15</property>


<!--the standard parameters for JDBC to control the number of preparedstatements loaded in the data source. But because the pre-cached statements belong to a single connection instead of the entire connection pool. So there are a number of factors that need to be taken into account in setting this parameter. Assuming that both maxstatements and maxstatementsperconnection are 0, the cache is closed. Default:0-->

<property name= "Maxstatements" >100</property>


<!--maxstatementsperconnection defines the maximum number of cache statements that a single connection in a connection pool has. Default:0--

<property name= "Maxstatementsperconnection" ></property>


<!--C3P0 is asynchronous, and a slow JDBC operation is completed by helping the process. Extending these operations effectively improves performance by multithreading to implement multiple operations at the same time being run.

Default:3-->

<property name= "Numhelperthreads" >3</property>


<!--when a user calls getconnection () to make the root user the user who is going to get the connection.

Used primarily when connection pooling is connected to a non-c3p0 data source. Default:null-->

<property name= "Overridedefaultuser" >root</property>


<!--a reference to use with the Overridedefaultuser parameter. Default:null-->

<property name= "Overridedefaultpassword" >password</property>


<!--password. Default:null-->

<property name= "Password" ></property>


<!--define test statements that are all connected to test runs. This one significantly increases the test speed in the case of a connection test. Note: The test table must exist at the initial data source. Default:null-->

<property name= "preferredtestquery" >select ID from test where id=1</property>


<!--user to change the system configuration parameters wait up to 300 seconds before running.

DEFAULT:300--

<property name= "Propertycycle" >300</property>


<!--use it only when you need it because of high performance consumption.

If set to true then the validity of each connection submission is officer.

It is recommended to use methods such as Idleconnectiontestperiod or automatictesttable to improve the performance of the connection test. Default:false--

<property name= "Testconnectiononcheckout" >false</property>


<!--Assuming true then the validity of the officer connection at the same time that the connection was made. Default:false--

<property name= "Testconnectiononcheckin" >true</property>


<!--username. Default:null-->

<property name= "User" >root</property>


Configuration in Hibernate (Spring Administration): <bean id= "DataSource" class= "Com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method= "Close" > <property name= "Driverclass" ><value>oracle.jdbc.driver.oracledriver</ value></property> <property name= "Jdbcurl" ><value>jdbc:oracle:thin: @localhost:1521:test< /value></property> <property name= "user" ><value>Kay</value></property> < Property Name= The minimum number of connections left in the connection pool for password ><value>root</value></property> <!--.

--<property name= "minpoolsize" value= "/> <!--the maximum number of connections left in the connection pool.

Default:15--<property name= "maxpoolsize" value= "1800"/> <!--maximum spare time, no connection is discarded if not used. If 0, it will never be discarded.

default:0--<property name= "MaxIdleTime" value= "1800"/> <!--when the connection in the connection pool is exhausted c3p0 the number of connections obtained at the same time. Default:3--<property name= "Acquireincrement" value= "3"/> <property name= "maxstatements" value= "1000" /> <property name= "initialpoolsize" value= "ten"/> <!--Check the spare connections in all connection pools every 60 seconds. default:0--<property name= "Idleconnectiontestperiod" value= "$"/> <!--defines the number of times to try repeatedly after a new connection has failed from the database.

Default:30--<property name= "acquireretryattempts" value= ""/> <property name= "BreakAfterAcquireFailu Re "value=" true "/> <property name=" Testconnectiononcheckout "value=" false "/> </bean>


  ########################### # # # c3p0 Connection pool### ########################### #hibernate. C3p0.max_size 2 #hibe Rnate.c3p0.min_size 2 #hibernate. c3p0.timeout #hibernate c3p0.max_statements #hibernate. c3p0.idle_test_ Period #hibernate. c3p0.acquire_increment 2 #hibernate. C3p0.validate False in the Hibernate.cfg.xml file, add configurations such as the following: <! --Maximum number of connections--<property name= "Hibernate.c3p0.max_size" >20</property> <!--minimum connections and <property NA Me= "Hibernate.c3p0.min_size" >5</property> <!--get the connection timeout, assuming that this time, throws an exception, in milliseconds--and <property name= " Hibernate.c3p0.timeout ">120</property> <!--the largest number of PreparedStatement and <property name=" Hibernate.c3p0.max_statements ">100</property> <!--Check the spare connection in the connection pool every 120 seconds. Units are seconds--<property name= "Hibernate.c3p0.idle_test_period" >120</property> <!--when the connection pool is exhausted. C3P0 get a new number of connections--<property name= "Hibernate.c3p0.acquire_increment" >2</property> <! --Verify that each connection is available--<property name= "Hibernate.c3p0.validate" >true</property>



C3P0 Specific configuration instructions (Com.mchange.v2.c3p0.ComboPooledDataSource)

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.