# druid使用

## 连接申请超时设定

配置参数为：

```markup
   <!-- 配置获取连接等待超时的时间 单位是毫秒 -->
   <property name="maxWait" value="10000"/>
   <property name="validationQuery" value="SELECT 'x'"/>
   <property name="validationQueryTimeout" value="2"/>
```

在1.0.23版本中，mysql的连接超时判断的方法还未被调用，超时时间的参数配置无效。 推荐升级到目前主流版本 1.0.29，在该版本，mysql的超时检测方法已被重载，要注意时间参数的单位为秒。 而且默认并不会调用validationQuery参数配置的sql语句，默认是使用ping的方式检测，ping检测方法也可以关闭 `-Ddruid.mysql.usePingMethod=false` ![](/files/-Lcei4TqBohSHFn1FLCf)

`validationQueryTimeout`是用来配置查询SQL的超时时间的，但是超时后会继续重试，而不是报错。`maxWait`参数才是真正确定了申请连接的超时时间，当一个申请连接操作达到`maxWait`指定的时间后便会抛出错误

## 配置监控

[Druid--基本配置及内置监控使用 - CSDN博客](https://blog.csdn.net/szzt_lingpeng/article/details/50612258)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.rizon.top/database/druid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
