gpt4 book ai didi

java - Apache DBCP 中的 maxWait 是什么?

转载 作者:行者123 更新时间:2023-12-03 20:29:28 24 4
gpt4 key购买 nike

我试图理解 最大等待 在 org.apache.commons.dbcp.BasicDataSource 中。 Documentation说是:

The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or <= 0 to wait indefinitely.



但我还是无法理解。我试图用谷歌搜索它,但我的怀疑只会增加。

我看到了两种解释这个定义的方法:
  • maxWait 是使用此池的应用程序将等待的最大毫秒数,直到它获得异常,如果池没有空闲连接返回到应用程序。 IE。如果池中没有空闲连接,应用程序将等待这段时间来建立新连接,直到出现异常。
  • maxWait 是可以打开连接的最大毫秒数。如果在这段时间内没有关闭此类连接,则池将引发异常。

  • 请帮助我理解哪个陈述是正确的。
    或者可能有其他定义:)

    最佳答案

    maxWait 应该是当所有连接当前都忙时,在抛出异常之前,您获取连接的调用将在池中等待的时间。

    您在 #2 中描述的行为似乎是日志放弃超时,这是在池决定它已被放弃之前可以租用连接多长时间(未关闭,这只会将其返回到池而不是实际关闭它.)

    查看 http://commons.apache.org/proper/commons-dbcp/configuration.html查看我所指的废弃设置。

    关于java - Apache DBCP 中的 maxWait 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29520735/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com