DruidDataSource connection pool configuration, druiddatasource connection

Source: Internet
Author: User

DruidDataSource connection pool configuration, druiddatasource connection

Data source connection pool Configuration

 

<Bean id = "dataSource" class = "com. alibaba. druid. pool. DruidDataSource" init-method = "init" destroy-method = "close">
<Property name = "driverClassName" value = "$ {jdbc. driverClassName}"/>
<Property name = "url" value = "$ {jdbc. url}"/>
<Property name = "username" value = "$ {jdbc. username}"/>
<Property name = "password" value = "$ {jdbc. password}"/>
<Property name = "filters" value = "stat"/>
The maximum number of database connections in the connection pool. If it is set to 0, there is no limit. You can set maxActive to a possible concurrency.
<Property name = "maxActive" value = "1000"/>
Initialization size
<Property name = "initialSize" value = "10"/>
Maximum number of waits in milliseconds, in MS. If this time is exceeded, an exception is received. If it is set to-1, there is no limit.
<Property name = "maxWait" value = "60000"/>
The maximum number of idle connections. Set 0 to no limit.
<Property name = "maxIdle" value = "100"/>
Minimum number of idle connections
<Property name = "minIdle" value = "10"/>
The time value of sleep during idle connection to the recycler thread running, in milliseconds. If it is set to a non-positive value, the idle connection to the recycler thread is not run.
<Property name = "timeBetweenEvictionRunsMillis" value = "60000"/>
Keep idle in the connection pool but not idle in connection with the recycler thread. Minimum Time Value for recycling, in milliseconds
<Property name = "minEvictableIdleTimeMillis" value = "300000"/>
SQL query is used to verify the connection obtained from the connection pool. If this parameter is specified before the connection is returned to the caller, the query must be an SQL SELECT statement and at least one row of records must be returned.
<Property name = "validationQuery" value = "SELECT 'x'"/>
Indicates whether the connection is verified by the idle connection recycler (if any). If the detection fails, the connection will be removed from the pool.
Note: If this parameter is set to true, the validationQuery parameter must be set to a non-null string.
<Property name = "testWhileIdle" value = "true"/>
Check whether the connection is retrieved from the pool. If the test fails, remove the connection from the pool and try to retrieve the other one. note: If this parameter is set to true, the validationQuery parameter must be set to a non-null string.
<Property name = "testOnBorrow" value = "false"/>
Indicates whether to perform a test before return to the pool
<Property name = "testOnReturn" value = "false"/>
Enable the prepared statement pool function of the pool.
<Property name = "poolPreparedStatements" value = "true"/>
<Property name = "maxPoolPreparedStatementPerConnectionSize" value = "50"/>
</Bean>

 

Related Article

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.