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

查看:131
本文介绍了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):

  • Apache DBCP - http://commons.apache.org/dbcp/
  • C3P0 - http://sourceforge.net/projects/c3p0

我在博客和其他论坛上看过很多关于它们的内容但是无法做出决定。

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个主要的重载消费者网络应用程序中使用了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天全站免登陆