Spring: DataSource: # Druid connection pool type: com.alibaba.druid.pool.DruidDataSource # database driver Driver: com.mysql.jdbc.Driver # The maximum number of connection pools max -active: 20 is established when the number of physical connection initialization # . Initialization occurs when the display calls the init method, the first or the getConnection Initial -size: 10 # getting connected to the maximum waiting time, in milliseconds. After configuring maxWait, fair lock is enabled by default, # concurrent efficiency will decline, if necessary, by using the configuration useUnfairLock property to true unfair lock. max -wait: 60000 # Number minimum connection pool min -idle: . 5 # has two meanings: # 1 : detecting intervals Destroy thread connection # 2: TestWhileIdle judgment basis, see detailed description of the property testWhileIdle Time -between-eviction-the runs of millis-: 60000 # Configure a minimum connection time survival pool milliseconds min -evictable-IDLE-Time-of millis: 180000 # used to detect whether the connection is valid sql, it requires a query. If validationQuery is null, testOnBorrow, testOnReturn, testWhileIdle will not its role. Validation -query: SELECT ' X ' # connection validity check timeout . 1 seconds Validation -query-timeout: . 1 executes the application # validationQuery connection detecting connection is valid, so this configuration can reduce performance. the Test -ON-BORROW: false # Set to check whether the time to get a connection from the connection pool availability, while true, if the connection is idle for more than minEvictableIdleTimeMillis checked or not checked; false, there are no checks the Test - the while -idle: to true execution validationQuery detect connection is valid, made this configuration can degrade performance when connected # return the Test -On- return : false # whether to cache preparedStatement, which is PSCache. PSCache support database cursors huge performance boost, for example oracle. Under the proposed closure of mysql. the pool -prepared-statements: to true # To enable PSCache, must be greater than zero configuration, when greater than 0, poolPreparedStatements triggered automatically changed to true. In the Druid, the # Oracle does not exist under PSCache over-consumption of memory problems, this value can configure some large, such as 100 max -open-the Prepared statements-: 20 # database link more than three minutes start to close idle connections seconds unit Remove -abandoned-timeout: 1800 # for connection not using forced closing Remove -abandoned: to true after the # is opened, the reinforcing timeBetweenEvictionRunsMillis periodically check the connection, is connected to an idle minIdle, # Connecting each inspection to verify the validity of the forced Reference: HTTPS:. // github.com/alibaba/druid/wiki/KeepAlive_cn Keep-Alive: to true # mergeSql opened by connectProperties function attributes; slow SQL record Connect -properties: Druid. = stat.mergeSql true ; druid.stat.slowSqlMillis = 5000 # close the connection timeout if the default is false, if it is true even if the database connection is restored, it can not connect BREAK the -after-acquire-failure: false # set obtain a connection error automatic reconnect times connection -error-the retry-attempts unsuccessful attempts: . 1 # retry setting acquisition during connection, - 1 is not a retry not -full-fimeout-the retry-COUNT: 2 # reconnection interval in milliseconds acquire -retry-Delay: 10000 # Set whether to get connected immediately return an error when an error, true to immediately return to Fail the -fast: to true # attribute type is a string, the configuration extension by way of an alias, common plug-ins are: # monitoring statistics used filter: stat log used filter: log4j defense sql injection filter: Wall Filters: STAT, Wall
In his summary of the work druid configuration is relatively complete, in order to solve the data connection timed out at the front desk prompted a server timeout information almost visited the whole druid profile
Problem Cause: When the network reasons, druid will not send the request to try to connect to the database, it will cause sockt obstruction.
Cause: Baidu, look at the source code (Note of no use, rely on guess), reconfigure DruidDataSource
Through unremitting efforts, Baidu oriented programming with rich experience, but also solve this problem.
Note: The background of any course will continue to try to connect to the database, can be resolved (in the configuration), but do not mind, it might cause the recovery is still connected to the network.
Renderings:
Thank big brother provided the following data,
https://blog.csdn.net/Swollow_/article/details/83624585 special thanks
https://www.jianshu.com/p/d7323afab808 special thanks
http://www.iigrowing.cn/?p=7551
https://www.cnblogs.com/jianzhixuan/p/6923216.html
https://blog.csdn.net/qq_34359363/article/details/72763491?locationNum=3&fps=1
Since I posted a company code, so the above useless url , the User , password see friends note