Premise:
Project Import DB2 Drive Jar Package
Driver package Download
> About DBCP
DBCP (database connection pool), DB connection pool. is a Java Connection pool project on Apache and a connection pool component used by Tomcat. Use of DBCP alone requires 3 packages: Commons-dbcp.jar,commons-pool.jar, Commons-collections.jar because establishing a database connection is a very time-consuming and resource-intensive behavior, the connection pool is pre-established with the database to make some connections, put in memory, the application needs to establish a database connection directly to the connection pool to apply for a line, run out and then put back.
Commons-dbcp.jar
Commons-pool.jar
Commons-collections.jar
>spring Configuration
Spring
<bean id= " Propertyconfigurer "class=" Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ">< Property Name= "Locations" ><list><value>classpath:application.properties</value></list ></property></bean>
<!--data source configuration, using the in-app DBCP database connection pool--><bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" Destroy-method= "Close" ><!--Connection Info--><property name= "Driverclassname" value= "${ Jdbc.driverclassname} "/><property name=" url "value=" ${jdbc.url} "/><property name=" username "value=" ${ Jdbc.username} "/><property name=" password "value=" ${jdbc.password} "/><!--Connection Pooling Info-- <property name= "Maxidle" value= "${dbcp.maxidle}"/><property name= "maxactive" value= "${dbcp.maxActive}"/ ><property name= "Defaultautocommit" value= "${dbcp.defaultautocommit}"/><property name= " Timebetweenevictionrunsmillis "value=" 3600000 "/><property name=" Minevictableidletimemillis "value=" 3600000 " /></bean>
Application.properties
Jdbc.driverclassname=com.ibm.db2.jcc.db2driverjdbc.url=jdbc:db2://192.168.19.111:50000/testjdbc.username= ADMINJDBC.PASSWORD=ADMIN#DBCP Settingsdbcp.maxidle=15dbcp.maxactive=600dbcp.defaultautocommit=true
> Add jar packages to your project
DBCP database Connection pool--Applicable to DB2 database