Configuring database connection pooling in Applicationcontext.xml

Source: Internet
Author: User
Tags connection pooling
What is meant by using ${} in the applicationcontext.xml.

In the Applicationcontext.xml file, use ${xxx} to indicate that a variable is called "xxx" inside {XXX}.   For example: Configure the data connection pool in the Applicationcontext.xml file <!--Configure Data Link pool--<property name= "DataSource" > <bean  class= "Com.mchange.v2.c3p0.ComboPooledDataSource" > <property name= "Jdbcurl"  value= "${ Jdbcurl} "></property> <property name=" Driverclass " value=" ${driverclass} "></ property> <property name= "user"  value= "${user}" ></property> <property name= " Password " value=" ${password} "></property> <!--other Configurations-<!--get three connections when initializing, The value should be between Minpoolsize and Maxpoolsize. Default:3--<property name= "Initialpoolsize"  value= "3" ></property> <!--the minimum number of connections left in the connection pool. Default:3--<property name= "Minpoolsize"  value= "3" ></property> <!--the maximum number of connections left in the connection pool. Default:15--<property name= "maxpoolsize"  value= "></property> <!-- When the connection in the connection pool runs out, c3p0 the number of connections that are fetched at one time. Default:3--&GT <property name= "Acquireincrement"  value= "3" ></property> <!-- Controls the number of PreparedStatement loaded in the data source. If both maxstatements and maxstatementsperconnection are 0, the cache is closed. default:0--<property name= "maxstatements"  value= "8" ></property> <!-- Maxstatementsperconnection defines the maximum number of cache statements that a single connection in a connection pool has. default:0--<property name= "Maxstatementsperconnection"  value= "5" ></property> <!-- Maximum idle time, unused in 1800 seconds, the connection is discarded. If 0, it will never be discarded. default:0--<property name= "MaxIdleTime"  value= "1800" ></property> </bean> </ The part that is identified in the property> code is the function that uses the ${}. It is equivalent to calling a variable name in Java. In this example, these variables come from a different properties file. The properties are: jdbc.properties (primarily used to store some of the configuration of the JDBC Connection database for the next change without needing to be modified in the Applicationcontext.xml file.) ) Jdbc.properties:jdbcurl=jdbc:mysql://localhost:3306/oa driverclass=com.mysql.jdbc.driver user=root password= ${ The Jdbcurl in Jdbcurl} refers to the Jdbcurl in Jdbc.properties.

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.