All Products
Document Center

Selection of Application Connection Pool

Last Updated: May 27, 2016

It is highly recommended that you connect a task with a connection pool. In the Java environment, DRUID serves as an application connection pool (, and is the most recommended connection pool. The components in the DRUID connection pool are well-tested and stable standard components released by Alibaba Corporation. They also implement monitoring and other functions.

Spring standard configuration of DRUID

<bean id="dataSource" class="" init-method="init" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <!—essential attribute url, user, password -->
        <property name="url" value="jdbc:mysql://ip:port/db?autoReconnect=true&amp;rewriteBatchedStatements=true&amp;socketTimeout=30000&amp;connectTimeout=3000" />
        <property name="username" value="root" />
        <property name="password" value="123456" />
        <!—configuration initialization size, minimum and maximum -->
        <property name="maxActive" value="20" />
        <property name="initialSize" value="3" />
        <property name="minIdle" value="3" />
        <!—maxWait timeout for waiting for obtaining of connection -->
        <property name="maxWait" value="60000" />

        <!—timeBetweenEvictionRunsMillis detection interval, idle connection to be closed for detection, with millisecond as unit -->
        <property name="timeBetweenEvictionRunsMillis" value="60000" />
        <!—minEvictableIdleTimeMillis minimum idle time of a connection in pool, with millisecond as unit-->
        <property name="minEvictableIdleTimeMillis" value="300000" />
        <property name="validationQuery" value="SELECT 'z'" />
        <property name="testWhileIdle" value="true" />
        <property name="testOnBorrow" value="false" />
        <property name="testOnReturn" value="false" />