DBCP Connection Pool configuration<bean id= "Dbcpdatasource" abstract= "true" >
<property name= "maxactive" value= "" "/><!--the maximum number of database connections for the connection pool. Set to 0 to indicate no limit. -
<property name= "InitialSize" value= "1"/><!--initialize the number of connections--
<property name= "maxwait" value= "60000"/><!--maximum setup connection wait time. If this time is exceeded, the exception will be received. Set to-1 to indicate no limit. -
<property name= "Maxidle" value= "" "/><!--the maximum number of waiting connections, set 0 to No limit--
<property name= "Minidle" value= "3"/><!--minimum number of waiting connections, set 0 to No Limit-
<property name= "removeabandoned" value= "true"/><!--Force self-interrupt to avoid DBCP itself bugs have been connected too long resource exhausted-
<property name= "removeabandonedtimeout" value= ""/><!--self-interrupt time seconds--
</bean> <bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" destroy-method= "close" par Ent= "Dbcpdatasource" >
<property name= "Driverclassname" value= "Com.mysql.jdbc.Driver"/>
<property name= "url" value= "Jdbc:mysql://127.0.0.1:3306/text?allowmultiqueries=yes"/>
<property name= "username" value= "root"/>
<property name= "Password" value= "root"/>
</bean>
About DBCP Connection pool The specific use of the method also need to refer to: Click to open the link dbcp jar package
Commons-dbpc.jar, Commons-collections.jar, commons-pool.jar download click to download
c3p0 Connection Pool configuration
<bean id= "C3p0datasource" abstract= "true" >
<property name= "Initialpoolsize" value= "1"/> <!--the number of connections obtained at initialization, the value should be between Minpoolsize and Maxpoolsize. Default:3--
<property name= "Minpoolsize" value= "1"/> <!--the minimum number of connections that are kept in the connection pool. -
<property name= "maxpoolsize" value= "/> <!--the maximum number of connections left in the connection pool. Default:15--
<property name= "MaxIdleTime" value= "/><!--maximum idle time, unused in 60 seconds is discarded. If 0, it will never be discarded. Default:0--
<property name= "Acquireincrement" value= "5"/><!--c3p0 the number of connections fetched at one time when the connection in the connection pool is exhausted. Default:3--
<property name= "idleconnectiontestperiod" value= "/> <!--check idle connections in all connection pools every 60 seconds. Default:0--
</bean>
<bean id= "DataSource" class= "Com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method= "Close" parent= " C3p0datasource ">
<property name= "Driverclassname" value= "Com.mysql.jdbc.Driver"/>
<property name= "url" value= "Jdbc:mysql://127.0.0.1:3306/text?allowmultiqueries=yes"/>
<property name= "username" value= "root"/>
<property name= "Password" value= "root"/>
</bean>
For more information on C3P0 connection pooling use: Click to open link
c3p0 jar Package
C3p0-0.9.2.jar Download Click to download
jdbc-pool Connection Pool configuration
<bean id= "Pooldatasource" abstract= "true" >
<property name= "maxactive" value= "Up"/> <!--the maximum number of database connections for the connection pool. Set to 0 to indicate no limit. -
<property name= "initialsize" value= "/> <!--number of connections initialized--
<property name= "maxwait" value= "10000"/> <!--maximum setup connection wait time. If this time is exceeded, the exception will be received. Set to-1 to indicate no limit. -
<property name= "removeabandonedtimeout" value= "/> <!--self-interrupt time seconds--
<property name= "Minevictableidletimemillis" value= "30000"/> <!--connection Timeout, default is half an hour. -
<property name= "Minidle" value= "ten"/> <!--minimum number of waiting connections, set to 0 No limit--
<property name= "Timebetweenevictionrunsmillis" value= "30000"/> <!--#运行判断连接超时任务的时间间隔 in milliseconds, default is-1, which means no tasks are performed. -
<property name= "jmxenabled" value= "true"/> <!--registered Pool JMX. The default value is true. -
<property name= "Testwhileidle" value= "false"/> <!--the default value is false when the idle connection in the connection pool is valid-
<property name= "Testonborrow" value= "true"/> <!--the default value is true, when fetching connections from the connection pool, verify that the connection is valid-
<property name= "Validationinterval" value= "30000"/> <!--check the interval between dead and alive (unit: mm) 0 or less check. The default is 0. -
<property name= "Testonreturn" value= "false"/> <!--The default value is Flase, and when you put the connection back into the connection pool, verify that the connection is
<property name= "Validationquery" value= "Select 1"/> <!--an SQL statement to verify that the database connection is healthy. This statement must be a query pattern and return at least one piece of data. Can be any sql--> to verify that the database connection is normal
<property name= "logabandoned" value= "true"/> <!--If an interrupt event is logged, the default is False-->
<property name= "removeabandoned" value= "true"/> <!--whether to automatically reclaim timeout connections--
<!-- These interceptors will be inserted into the chain by an Java.sql.Connection object that operates on an interceptor. The default value is empty.
Pre-defined interceptors:
Org.apache.tomcat.jdbc.pool.interceptor.ConnectionState-Track autocommit, read-only directory, and transaction isolation level.
Org.apache.tomcat.jdbc.pool.interceptor.tatementFinalizer-Tracks open statements and returns to the pool when the connection is closed. -->
<property name= "jdbcinterceptors "Value=" Org.apache.tomcat.jdbc.pool.interceptor.connectionstate;o Rg.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer "/>
</bean>
Note: Add the values of the following 4 attributes to the connection pool, validationquery is required, and Testonborrow,testonreturn,testwhileidle is based on validationquery to verify that the connection is valid
<bean id= "DataSource" class= "Org.apache.tomcat.jdbc.pool.DataSource" destroy-method= "Close" parent= " Pooldatasource ">
<property name= "Driverclassname" value= "Com.mysql.jdbc.Driver"/>
<property name= "url" value= "Jdbc:mysql://127.0.0.1:3306/text?allowmultiqueries=yes"/>
<property name= "username" value= "root"/>
<property name= "Password" value= "root"/>
</bean>
For more information about Tomcat JDBC Pool connection pooling, please refer to: Click to open link
Jdbc-pool jar Package
Commons-dbpc.jar, Commons-collections.jar, commons-pool.jar download click to download
Driverclass and Jdbcurl of common database
Database |
Driverclass |
Jdbcurl |
SQL Server |
Com.microsoft.sqlserver.jdbc.SQLServerDriver |
Jdbc:sqlserver://127.0.0.1:1433;databasename=schoolmis_new |
My SQL |
Com.mysql.jdbc.Driver |
Jdbc:mysql://127.0.0.1:3306/azmis?allowmultiqueries=yes |
Oracle |
Oracle.jdbc.driver.OracleDriver |
Jdbc:oracle:thin: Database name/database password@localhost:1521: Global database name |
SQL server2000/2005/2008, MY SQL, orcal driver package
Download Click to download