Spring JDBC连接池的最佳实践 [英] Spring JDBC connection pool best practices

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

问题描述

我有一个基本的Spring JDBC应用程序,它具有非常基本的配置:

I have a basic Spring JDBC application with a pretty basic configuration:

<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
   <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
   <property name="url" value="jdbc:oracle:thin:@1.1.1.1:1521:XXX"/>
   <property name="username" value="username"/>
   <property name="password" value="password"/>
</bean>

<bean id="dbThing" class="com.DbThing">
   <property name="dataSource" ref="myDataSource"/>
</bean>

我想介绍一个连接池,在这里阅读几个线程后我就有点了关于使用哪个池库感到困惑。

I would like to introduce a connection pool and after reading several threads here on SO I'm a bit confused about which pooling library to use.

似乎在SO上有更多信用的库是 CP30 DBCP 。由于我使用的是Oracle,因此我也可以使用汇总数据源。驱动程序。
我知道有更多的库可用 - 例如新的Apache Tomcat 7池库。

The libraries that seems to have more credits on SO are CP30 and DBCP. Since I'm using Oracle, I could also use the pooled data source offered by the driver. I understand that there are more libraries available - for instance the new Apache Tomcat 7 pooling libraries.

我应该避免使用任何库吗?

Is there any library that I should really avoid?

我应该对给定的库使用任何推荐的配置吗?

Is there any recommended configuration I should use with a given library?

你关心的任何战争故事分享?

Any "war story" you care to share?

推荐答案

C3PO和DBCP的发展已停滞不前,主要是因为它们已经成熟。我已经看到这两个驱动程序每秒能够支持数百个事务。

C3PO and DBCP development have stalled mostly because they are mature. I have seen both of these drivers be able to support hundreds of transactions per second.

Tomcat池是一个重做的&更新了DBCP驱动程序。 MyBatis 3.0还包含它自己的池实现,基于代码检查,它看起来很可靠。最后, BoneCP 声称拥有最佳性能。我还没有在项目中使用任何这些。

The Tomcat pool is a reworked & updated DBCP driver. MyBatis 3.0 also contains it's own pooling implementation which, based on code inspection, seems solid. Finally, there's BoneCP which claims to have the best performance. I haven't used any of these on a project yet.

可能最好的建议是挑选任何一个测试它。 Spring可以让以后轻松换出。

Probably the best advice is to pick any of them test it. Spring makes it easy to swap out later.

这篇关于Spring JDBC连接池的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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