Druid connection pool

Source: Internet
Author: User

Druid is a database connection pool first, but it is not just a database connection pool. It also contains a proxydriver, a series of built-in JDBC component libraries, and an SQL parser.

  • Maven Configuration

Add the following configuration section in the Pom. xml file --

1 <dependency>2   <groupId>com.alibaba</groupId>3   <artifactId>druid</artifactId>4   <version>${druid-version}</version>5 </dependency>
  • Spring data source configuration

Add the following configuration section in the spring configuration file --

 1 <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">    2     <property name="url" value="${jdbc_url}" />   3     <property name="username" value="${jdbc_user}" />   4     <property name="password" value="${jdbc_password}" />   5         6     <property name="filters" value="stat" />   7     8     <property name="maxActive" value="20" />   9     <property name="initialSize" value="1" />  10     <property name="maxWait" value="60000" />  11     <property name="minIdle" value="1" />  12    13     <property name="timeBetweenEvictionRunsMillis" value="60000" />  14     <property name="minEvictableIdleTimeMillis" value="300000" />  15    16     <property name="validationQuery" value="SELECT ‘x‘" />  17     <property name="testWhileIdle" value="true" />  18     <property name="testOnBorrow" value="false" />  19     <property name="testOnReturn" value="false" />  20        21     <property name="poolPreparedStatements" value="true" />  22     <property name="maxPoolPreparedStatementPerConnectionSize" value="50" />  23 </bean>
  • Web Monitoring page configuration

Add the following configuration section in Web. XML to perform monitoring through http: // {IP }:{ port}/druid.

1 <servlet>2     <servlet-name>DruidStatView</servlet-name>3     <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>4 </servlet>5 <servlet-mapping>6     <servlet-name>DruidStatView</servlet-name>7     <url-pattern>/druid/*</url-pattern>8 <servlet-mapping>
View code

 

Druid connection pool

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.