OracleDataSource 与 Oracle UCP PoolDataSource

OracleDataSource vs. Oracle UCP PoolDataSource(OracleDataSource 与 Oracle UCP PoolDataSource)
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)