Hibernate - 连接池中的连接未关闭
我正在使用 org.apache.commons.dbcp.BasicDataSource 并且我想监视未关闭的连接。 我必须在休眠配置文件中设置哪些属性?
谢谢。 乔万尼
I am using org.apache.commons.dbcp.BasicDataSource and I want to monitor the UNCLOSED connections.
What properties i have to set in hibernate config file?
Thanks.
Giovanni
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更新 log4j 配置可能会有所帮助,以便将 c3p0 配置打印到日志文件中。只需将类别 com.mchange.v2.c3p0 设置为“信息”即可。我很难获取我的 c3p0 配置文件,所以也许你的配置文件也没有被读取。
It might be helpful to update your log4j configuration so the c3p0 config is printed to your log file. Just set category com.mchange.v2.c3p0 to "info". I'm having great difficulty getting my c3p0 configuration file to be picked up, so maybe yours isn't being read either.
我不确定这是否受 DBCP 支持(如果是,也许添加文档链接)。
但是,应该可以使用 C3P0 和以下属性(请参阅此之前的答案):
unreturnedConnectionTimeout
(设置它大于0
的值)debugUnreturnedConnectionStackTraces
(将其设置为true
)您必须在
c3p0.propeties
中设置它们(请参阅附录 C:Hibernate 特定注释)。另一种选择是使用 BoneCP。
但我想知道为什么你需要这个,我很确定 Hibernate 不会泄漏连接。
I am not sure this is something supported by DBCP (if it is, maybe add a link to the documentation).
However, it should be possible using C3P0 and the following properties (see this previous answer):
unreturnedConnectionTimeout
(set it to a value greater than0
)debugUnreturnedConnectionStackTraces
(set it totrue
)You'll have to set them in the
c3p0.propeties
(see Appendix C: Hibernate-specific notes).Another option would be to use BoneCP.
But I wonder why you need this, I'm pretty sure Hibernate is not leaking connections.