More database configuration items are available for easy administration by using link pooling than direct linking.
Now the common open source data connection pool mainly has c3p0,
Dbcp and Proxool three species, of which:
? The Hibernate Development Group recommends the use of c3p0;
? The Spring Development Group recommends the use of DBCP (DBCP connection pool has
WebLogic connection pooling The same problem is forcing the shutdown
After a connection or a database restart, it is not possible to reconnect
The connection is reset, this setting can be resolved
<!--configuring DBCP data Sources--
<bean id= "DataSource2" destroy-method= "Close" class= "Org.apache.commons.dbcp.BasicDataSource" >
<property name= "Driverclassname" value= "Com.mysql.jdbc.Driver"/>
<property name= "url" value= "Jdbc:mysql://127.0.0.1:3306/goods?characterencoding=utf-8"/>
<property name= "username" value= "root"/>
<property name= "Password" value= "123456"/>
<!--the number of connections created when the pool is started-
<property name= "InitialSize" value= "5"/>
<!--The maximum number of connections that can be allocated from the pool at the same time. When set to 0, it means no limit. -
<property name= "maxactive" value= "/>"
<!--the maximum number of idle connections that will not be released in the pool. When set to 0, it means no limit. -
<property name= "Maxidle" value= "/>"
<!--the minimum number of connections that remain idle in the pool without creating a new connection. -
<property name= "Minidle" value= "3"/>
<!--Set auto-recycle timeout connection--
<property name= "removeabandoned" value= "true"/>
<!--auto-reclaim time-out (in seconds)--
<property name= "removeabandonedtimeout" value= "/>"
<!--set the time-out error for print connection when auto-recycle timeout connection
<property name= "logabandoned" value= "true"/>
<!--wait timeout in milliseconds, the maximum time the pool waits for a connection to be reclaimed (when no connection is available) before throwing an exception. Set to 1 to indicate an infinite wait. -
<property name= "maxwait" value= "/>"
</bean>
<!--configuring C3P0 data Sources--
<bean id= "DataSource" class= "Com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method= "Close" >
<property name= "Driverclass" value= "Com.mysql.jdbc.Driver"/>
<property name= "Jdbcurl" value= "Jdbc:mysql://127.0.0.1:3306/goods?characterencoding=utf-8"/>
<property name= "User" value= "root"/>
<property name= "Password" value= "123456"/>
<!--The maximum number of connections that are kept in the connection pool. Default:15--
<property name= "maxpoolsize" value= "/>"
<!--the minimum number of connections that are kept in the connection pool. -
<property name= "Minpoolsize" value= "ten"/>
<!--the number of connections obtained when initializing, the value should be between Minpoolsize and Maxpoolsize. Default:3--
<property name= "Initialpoolsize" value= "ten"/>
<!--maximum idle time, unused in 60 seconds, the connection is discarded. If 0, it will never be discarded. Default:0--
<property name= "maxidletime" value= "/>"
<!--c3p0 The number of connections that are fetched at the same time when the connection in the connection pool is exhausted. Default:3--
<property name= "Acquireincrement" value= "5"/>
<!--the standard parameters of JDBC to control the number of preparedstatements loaded within the data source. But due to the statements of the pre-cache
belong to a single connection instead of the entire connection pool. So setting this parameter takes into account a variety of factors.
If both maxstatements and maxstatementsperconnection are 0, the cache is closed. Default:0-->
<property name= "maxstatements" value= "0"/>
<!--check for idle connections in all connection pools every 60 seconds. Default:0--
<property name= "idleconnectiontestperiod" value= "/>"
<!--defines the number of repeated attempts to obtain a new connection from the database after a failure. Default:30--
<property name= "acquireretryattempts" value= "/>"
<!--getting a connection failure will cause any thread that waits for the connection pool to get the connection to throw an exception. But the data source is still valid
Reserved and continue trying to get the connection the next time you call Getconnection (). If set to true, then try to
When a connection failure is obtained, the data source declares that it has been fractured and closed permanently. Default:false-->
<property name= "Breakafteracquirefailure" value= "true"/>
<!--use it only when you need it, due to its high performance consumption. If set to true then each connection commits the
Officer the validity of the test. It is recommended to use Idleconnectiontestperiod or automatictesttable
and other methods to improve the performance of the connection test. Default:false--
<property name= "Testconnectiononcheckout" value= "false"/>
</bean>
Spring Link Pool