DBCP database Connection pool--Applicable to DB2 database

Source: Internet
Author: User
Tags connection pooling

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

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.