SSM Database Connection Pool configuration

Source: Internet
Author: User
Tags sql injection

1, the project introduced Druid-1.1.2.jar package
2. Modify the Spring-common.xml file

<!--1. Data Source: Druiddatasource -    <BeanID= "DataSource"class= "Com.alibaba.druid.pool.DruidDataSource"Init-method= "Init"Destroy-method= "Close">        < Propertyname= "Driverclassname"value= "Com.mysql.jdbc.Driver" />        < Propertyname= "url"value= "jdbc:mysql://127.0.0.1:3306/database name?useunicode=true&amp;characterencoding=utf-8&amp; Zerodatetimebehavior=converttonull " />        < Propertyname= "username"value= "Account Number" />        < Propertyname= "Password"value= "Password" />                <!--The property type is a string, the extension is configured by alias, and the common plug-ins are: Filter:stat log for monitoring statistics with FILTER:LOG4J Defense SQL injection Filter:wall -        < Propertyname= "Filters"value= "Stat"/>        <!--maximum number of connection pools -        < Propertyname= "Maxactive"value= "+"/>        <!--the number of physical connections that were established when initializing. Initialization occurs when a call to the Init method is displayed, or the first time getconnection -        < Propertyname= "InitialSize"value= "1"/>        <!--gets the maximum wait time, in milliseconds, for a connection. After Maxwait is configured, a fair lock is enabled by default, and concurrency efficiency decreases, and if necessary, an unfair lock can be used by configuring the Useunfairlock property to True.  -        < Propertyname= "Maxwait"value= "60000"/>        <!--minimum number of connection pools -        < Propertyname= "Minidle"value= "1"/>        <!--How often the configuration interval is detected to detect idle connections that need to be closed, in milliseconds -        < Propertyname= "Timebetweenevictionrunsmillis"value= "60000"/>        <!--configures the minimum lifetime of a connection in a pool, in milliseconds -        < Propertyname= "Minevictableidletimemillis"value= "300000"/>        <!--The SQL that is used to detect whether a connection is valid is a query statement. If the validationquery for Null,testonborrow, Testonreturn, Testwhileidle will not function.  -        < Propertyname= "Validationquery"value= "Select ' X '"/>        <!--It is recommended to configure true to not affect performance and ensure security. Detect when the connection is requested, if idle time is greater than Timebetweenevictionrunsmillis, perform validationquery to detect if the connection is valid -        < Propertyname= "Testwhileidle"value= "true"/>        <!--when you request a connection, perform validationquery to detect if the connection is valid, and this configuration will degrade performance -        < Propertyname= "Testonborrow"value= "false"/>        <!--when you return the connection, perform validationquery to detect if the connection is valid, and this configuration will degrade performance -        < Propertyname= "Testonreturn"value= "false"/>    </Bean>

SSM Database Connection Pool configuration

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.