JDBC 连接池选项:DBCP 与 C3P0 [英] Connection pooling options with JDBC: DBCP vs C3P0

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

问题描述

可用于 Java/JDBC 的最佳连接池库是什么?

What is the best connection pooling library available for Java/JDBC?

我正在考虑 2 个主要候选者(免费/开源):

I'm considering the 2 main candidates (free / open-source):

我在博客和其他论坛上阅读了很多关于它们的内容,但无法做出决定.

I've read a lot about them in blogs and other forums but could not reach a decision.

这两者是否有相关的替代方案?

Are there any relevant alternatives to these two?

推荐答案

DBCP 已过时且不是生产级.前段时间,我们对两者进行了内部分析,创建了一个测试装置,它针对两者生成负载和并发性,以评估它们在现实生活条件下的适用性.

DBCP is out of date and not production grade. Some time back we conducted an in-house analysis of the two, creating a test fixture which generated load and concurrency against the two to assess their suitability under real life conditions.

DBCP 始终在我们的测试应用程序中生成异常,并努力达到 C3P0 能够无异常处理的性能水平.

DBCP consistently generated exceptions into our test application and struggled to reach levels of performance which C3P0 was more than capable of handling without any exceptions.

C3P0 还稳健地处理了数据库断开连接和恢复时的透明重新连接,而如果从其下方取出链接,则 DBCP 永远不会恢复连接.更糟糕的是,DBCP 正在将 Connection 对象返回给底层传输已中断的应用程序.

C3P0 also robustly handled DB disconnects and transparent reconnects on resume whereas DBCP never recovered connections if the link was taken out from beneath it. Worse still DBCP was returning Connection objects to the application for which the underlying transport had broken.

从那时起,我们在 4 个主要的重载消费类 Web 应用中使用了 C3P0,并且从未回头.

Since then we have used C3P0 in 4 major heavy-load consumer web apps and have never looked back.

更新:事实证明,在搁置多年之后,Apache Commons 的人们已经采取了 DBCP 脱离休眠,现在它再次成为一个积极开发的项目.因此,我原来的帖子可能已经过时了.

UPDATE: It turns out that after many years of sitting on a shelf, the Apache Commons folk have taken DBCP out of dormancy and it is now, once again, an actively developed project. Thus my original post may be out of date.

话虽如此,我还没有体验过这个新升级的库的性能,也没有听说它在任何最近的应用程序框架中都是事实.

That being said, I haven't yet experienced this new upgraded library's performance, nor heard of it being de-facto in any recent app framework, yet.

这篇关于JDBC 连接池选项:DBCP 与 C3P0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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