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&characterencoding=utf-8& 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