druid连接池默认配置
时间: 2024-02-02 16:03:52 浏览: 22
Druid连接池的默认配置是:
initialSize = 0
maxActive = 8
minIdle = 0
maxWait = -1
timeBetweenEvictionRunsMillis = 60000
minEvictableIdleTimeMillis = 300000
validationQuery = "SELECT 'x'"
testWhileIdle = true
testOnBorrow = false
testOnReturn = false
poolPreparedStatements = true
maxOpenPreparedStatements = -1
filters = "stat"
相关问题
druid查看连接池数量
可以通过Druid提供的监控页面查看Druid连接池的相关信息,包括连接池数量。
具体步骤如下:
1. 在Spring Boot项目中引入Druid依赖,添加如下配置:
```properties
# 配置Druid连接池监控页面
spring.datasource.druid.stat-view-servlet.enabled=true
spring.datasource.druid.stat-view-servlet.url-pattern=/druid/*
spring.datasource.druid.stat-view-servlet.login-username=admin
spring.datasource.druid.stat-view-servlet.login-password=admin
```
2. 启动Spring Boot应用,访问Druid监控页面,在页面上可以看到连接池的相关信息。
默认情况下,Druid连接池数量为8,可以通过配置文件进行修改:
```properties
spring.datasource.druid.initial-size=10
spring.datasource.druid.min-idle=5
spring.datasource.druid.max-active=50
```
其中:
- `initial-size`:初始化连接池数量,默认为0。
- `min-idle`:连接池中最小空闲连接数量,默认为8。
- `max-active`:连接池中最大连接数量,默认为8。
druid 连接池 最大等待时间 缺省启用公平锁
根据Druid官方文档,Druid连接池有关于等待最长时间和公平锁的配置项。具体解答如下:
1. Druid连接池的最大等待时间配置项为maxWait,用于配置一个连接在获取不到时最长的等待时间。如果超时则会抛出SQLException,但是如果一个连接在最小空闲时间内创建,则不会限制其最长使用时间。此配置的默认值为-1,表示没有限制。
2. Druid连接池缺省启用公平锁。在连接池配置中,fair和fairQueue两个属性控制公平锁的使用。默认情况下,fair=false,即是非公平锁。但是fairQueue默认为true,表示采用公平的等待队列。
参考文献:
- <<Druid连接池配置>> [^1]
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)