OracleDataSource 与 Oracle UCP PoolDataSource [英] OracleDataSource vs. Oracle UCP PoolDataSource

查看:26
本文介绍了OracleDataSource 与 Oracle UCP PoolDataSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在研究一些 JDBC Oracle 连接池项目时遇到了一个新的(更)Oracle 池实现,称为通用连接池 (UCP).现在它使用一个新类 PoolDataSource 用于连接池,而不是 OracleDataSource [启用缓存选项].我正在争论是否要切换到这个新的实现,但找不到任何好的文档来说明这会给我带来什么(如果有的话)修复/升级.任何人都有这两者的经验?优点/缺点?谢谢.

I was researching some JDBC Oracle Connection Pooling items and came across a new(er) Oracle Pool implementation called Universal Connection Pool (UCP). Now this uses a new class, PoolDataSource, for connection pooling rather then the OracleDataSource [with the cache option enabled]. I am debating whether to switch to this new implementation but can't find any good documentation of what (if any) fixes/upgrades this would buy me. Anyone have an experience with both? Pluses/Minuses? Thanks.

推荐答案

最新的 Oracle jdbc 驱动程序 (11.2.0.1.0) 明确指出 Oracle 隐式连接缓存(即使用 OracleDataSource 的缓存)已弃用:

Latest Oracle jdbc driver (11.2.0.1.0) explicit states that Oracle Implicit Connection cache (which is that one that use OracleDataSource) it's deprecated :

通用连接池在此版本中,Oracle 隐式连接缓存特性是已弃用.强烈鼓励用户使用新的 Universal连接池代替.UCP 具有所有的功能ICC,还有更多.UCP 在单独的 jar 文件中可用,ucp.jar.

Oracle JDBC Drivers release 11.2.0.1.0 production Readme.txt

What Is New In This Release ?

Universal Connection Pool In this release the Oracle Implicit Connection Cache feature is deprecated. Users are strongly encouraged to use the new Universal Connection Pool instead. The UCP has all of the features of the ICC, plus much more. The UCP is available in a separate jar file, ucp.jar.

所以我认为最好开始使用 UCP,但是文档不是那么好.例如我没有找到将 UCP 与 spring 一起使用的方法...

So I think it's better to start using UCP, but the documentation it's not that good. For example I didn't find a way to use UCP with spring...

更新:我找到了正确的弹簧配置:好的,我想我找到了正确的配置:

UPDATE: I've found the correct spring configuration: OK I think I've found the right configuration:

<bean id="dataSource" class="oracle.ucp.jdbc.PoolDataSourceFactory" factory-method="getPoolDataSource">
    <property name="URL" value="jdbc:oracle:thin:@myserver:1521:mysid" />
    <property name="user" value="myuser" />
    <property name="password" value="mypassword" />
    <property name="connectionFactoryClassName" value="oracle.jdbc.pool.OracleDataSource" />
    <property name="connectionPoolName" value="ANAG_POOL" />
    <property name="minPoolSize" value="5" />
    <property name="maxPoolSize" value="10" />
    <property name="initialPoolSize" value="5" />
    <property name="inactiveConnectionTimeout" value="120" />
    <property name="validateConnectionOnBorrow" value="true" />
    <property name="maxStatements" value="10" />
</bean>

关键是指定正确的工厂类和正确的工厂方法

The key is to specify the right factory class and the right factory method

这篇关于OracleDataSource 与 Oracle UCP PoolDataSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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