java - Apache DBCP defaultQueryTimeout 需要哪些单位?

标签 java apache-commons-dbcp

Apache Commons DBCP 的 documentation状态,即

defaultQueryTimeout
If non-null, the value of this Integer property determines the query timeout that will be used for Statements created from connections managed by the pool. null means that the driver default will be used.

但他们忘记提及他们期望的[时间]单位。 Javadoc 中也存在同样的健忘情况。

我假设超时以秒为单位,因为 validationQueryTimeout 期望超时以秒为单位,但这只是一个假设。

那么什么单位适用于 defaultQueryTimeout ?还秒?

最佳答案

这两个值的有效单位是秒。

所需信息可在类 BasicDataSource 的 Javadoc 中找到。

getDefaultQueryTimeout 
[***]
Returns:
The default query timeout in seconds.

getValidationQueryTimeout
[***]
Returns:
the timeout in seconds before connection validation queries fail.

您还可以阅读 source code of this class了解更多信息

关于java - Apache DBCP defaultQueryTimeout 需要哪些单位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60186821/

相关文章:

java - @BeforeAll 和 @Transaction 不起作用 - 数据库端的更改不会回滚

java - 使用 Hibernate 和 Apache DBCP 的 MySQL 的连接池问题

java - 哪个 Java 数据库 API 最容易使用?

java - 查询运行缓慢

java - 如何配置 DBCP PoolableConnectionFactory?

java - 从 DUAL : MySQL 中选择 1

java - 强制急切初始化 Tomcat 处理的数据源

java - 在自定义 java 类中反序列化 MapWritable

java - libgdx 中纹理的控制

java - ApplicationContext 事件从未被抛出