适用于生产环境的最强大的数据源
我使用 DriverManagerDataSource 进行本地开发。我目前正在使用 org.apache.commons.dbcp.BasicDataSource ,因为创建了太多连接。
有没有人对在连接池方面为客户端在生产中设置数据库的最佳方法有什么建议?
I was using DriverManagerDataSource
for local development. I am currently using org.apache.commons.dbcp.BasicDataSource
now because too many connections were being created.
Does anyone have suggestions on what the best way to go about setting up database in production for client is in terms of connection pools?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看BoneCP,速度相当快。
除了所有示例之外,还有常见问题解答,它可以为您提供有关连接池、角落的非常简洁和漂亮的概述案例,以及 BoneCP 如何处理它们。
Take a look a t BoneCP, it is quite fast.
Besides all the examples, there is FAQ that would give you a very concise and nice overview of connection pooling, corner cases, and how BoneCP handles them.
我通常倾向于使用 C3P0。对我来说总是很顺利。实际上并没有做过任何更深入的分析或比较,因为C3P0在性能和功能方面一直“足够好”。
I usually tend to go for C3P0. It's always worked out fine for me. Haven't actually done any deeper analysis or comparisons since C3P0 has always been "good enough" in terms of performance and functionality.
是的,我强烈建议为生产就绪的应用程序使用池数据源。
DriverManagerDataSource
和Single-ConnectionDataSource
均提供连接池,无需设置池配置属性。虽然
SingleConnectionDataSource
和DriverManagerDataSource
很棒对于小型应用程序和在开发中运行的应用程序,您应该认真考虑在生产应用程序中使用其中任何一个的影响。由于
SingleConnection-DataSource
只有一个数据库连接可供使用,因此它在多线程应用程序中无法正常工作。同时,即使DriverManager-DataSource
能够支持多线程,它也会因每次请求连接时创建新连接而产生性能成本。由于这些限制,我强烈建议使用池数据源。我展示了示例池数据源配置
Yes,I strongly recommend using pooled data sources for Production ready applications.
DriverManagerDataSource
norSingle-ConnectionDataSource
provides a connection pool, there are no pool configuration properties to set.Although
SingleConnectionDataSource
andDriverManagerDataSource
are greatfor small applications and running in development, you should seriously consider the implications of using either in a production application. Because
SingleConnection-DataSource
has one and only one database connection to work with, it doesn’t work well in a multithreaded application. At the same time, even thoughDriverManager-DataSource
is capable of supporting multiple threads, it incurs a performance cost for creating a new connection each time a connection is requested. Because of these limitations, I strongly recommend using pooled data sources.I've shown sample Pooled DataSource configuration