DBCP 连接池登录超时 [英] DBCP Connection Pool loginTimeout

查看:46
本文介绍了DBCP 连接池登录超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 DBCP文档,BasicDataSource 不支持 setLoginTimeout().我的问题是如何设置 LoginTimeout 来创建 Connection 对象?我知道我可以在池上设置 maxWait,但我的理解是,这只会在池用完并且您正在等待现有连接释放时使用.它不会让我摆脱需要创建新连接但连接/登录数据库挂起的情况.

感谢任何帮助.谢谢.

解决方案

总有一个选项可以向 URL 添加正确的参数.根据您使用的数据库,您可以在 JDBC url 中添加参数之一.

这是确认 BasicDataSource 不支持 loginTimeout 的链接p>

在这篇博客的底部 有一个表格列出了连接超时的 URL 参数.

According to the DBCP Document, BasicDataSource does not support setLoginTimeout(). My question is then how do I set a LoginTimeout for the creation of Connection objects? I know I can set maxWait on the pool, but my understanding is that that'll only be used for when the pool is exhausted and you're waiting for an existing connection to free up. It will not save me from the situation where a new connection needs to be created, but the connection/login into the DB hangs.

Any help is appreciated. Thanks.

解决方案

Well there is always an option to add correct parameter to the URL. Depending on which DB you are using you can add one of the parameters in JDBC url.

Here is the link that confirms that BasicDataSource does not support loginTimeout

And at the bottom of this blog There is a table which lists URL parameters for connection timeouts.

这篇关于DBCP 连接池登录超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆