Proxool最大连接数
我正在使用 proxool java 连接池(版本 0.9.1)。 一切正常,直到达到最大连接数。 如果达到最大连接数,proxool 会立即抛出 SQLException
:
java.sql.SQLException: Couldn't get connection because we are at maximum
connection count (n/n) and there are none available
当然,显示的不是 n
而是最大连接数。
为什么 proxool 立即抛出 SQLException
而不是等待可用连接? 当然不是永远,但可配置的超时会很棒。
我不知道这是否重要,但我在 Tomcat J2EE 应用程序中使用 proxool。 proxool 的参数在 context.xml
中定义,我正在使用 Proxool 数据源支持。
I'm using proxool java connection pool (version 0.9.1). Everything works fine till I reach the maximum connection count. If the maximum connection count is reached proxool immediately throws an SQLExcepion
:
java.sql.SQLException: Couldn't get connection because we are at maximum
connection count (n/n) and there are none available
Of course instead of n
the maximum connection count is shown.
Why is proxool throwing an SQLException
immediately instead of waiting for an available connection? Not forever of course, but a configurable timeout would be great.
I don't know if it important, but I'm using proxool in a Tomcat J2EE application. Parameters of proxool are defined in context.xml
and I'm using Proxool DataSource Support.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在 proxool 邮件列表上提出问题,但不幸的是,我得到了一个负面的 答案。
现在不支持可配置(或任何类型)超时,但有计划实现此功能。
I was asking the question on the proxool mailing list and I got a quick, yet unfortunately negative answer.
Now there is no support for configurable (or any kind of) timeout, however there are plans to implement this feature.
我快速浏览了源代码,这看起来像是 ConnectionPool.getConnection 的标准行为。 文档也说了同样的事情。
还有其他数据库池库(例如 Apache DBCP 和 C3P0),但您必须进行一些重构才能使用它们。 另一种方法是自己包装 getConnection 方法(或修改 proxool 源代码)并使其按照您想要的方式工作。
I took a quick look at the source code and this looks like the standard behavior for ConnectionPool.getConnection. The documentation says the same thing.
There are other database pooling libraries (such as Apache DBCP and C3P0) but you'd have to do some refactoring to use them. The alternative is to wrap the getConnection method yourself (or modify the proxool source) and make it work the way you want.
您可以使用 Thread.sleep() 来处理它。
当达到最大连接数时,Proxool 会抛出异常。 一旦检测到它,您可以通过调用“Thread.sleep()”等待一段时间,希望在这段时间之后,连接将再次可用。
You can use Thread.sleep() to handle it.
Proxool throws an exception when the maximum connection number is reached. Once you detect it, you can wait for a little while by calling "Thread.sleep()", hopefully after this amount of time, the connections will be available again.