【问题标题】:Connection Pooling is not working for DB2 database through UCP连接池不适用于通过 UCP 的 DB2 数据库
【发布时间】:2019-12-29 11:27:00
【问题描述】:

我们正在编写一个简单的独立 java 批处理。我们正在使用 DB2 数据库。我们正在尝试使用 UCP(版本:ucp-11.2.0.3.0)进行连接池。

我们已将最小池大小初始化为 5。但是当我们检索一个连接并打印 Available 和 Borrowed 连接时,我们得到 Available 为 0 和 Borrowed 为 1。当检索多个连接时,它仍在打印即使最小池大小为 5,也一样。即使超过了最大限制,我们也没有得到任何异常。您能帮我们解决这个问题吗?

PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();

pds.setConnectionFactoryClassName("XXXX");

pds.setURL("XXX");

pds.setUser("CCCC");

pds.setPassword("xxx");

pds.setInitialPoolSize(1);

pds.setMinPoolSize(5);

pds.setMaxPoolSize(10);

connection = pds.getConnection();

System.out.println("\nConnection borrowed from the pool");

int avlConnCount = pds.getAvailableConnectionsCount();

System.out.println("\nAvailable connections: " + avlConnCount);

int brwConnCount = pds.getBorrowedConnectionsCount();

System.out.println("\nBorrowed connections: " + brwConnCount);
Output:
-------
Connection borrowed from the pool

Available connections: 0

Borrowed connections: 1

Connection borrowed from the pool

Available connections: 0

Borrowed connections: 1

【问题讨论】:

  • 您为什么认为 Oracle UCP 应该与 Db2 一起使用? IBM 似乎只支持 Oracle 数据库的 UCP(通过 WAS)。

标签: java db2 ucp


【解决方案1】:

UCP 是 Oracle 数据库的连接池库。 Db2 没有自带连接池库,而是与主要的连接池库配合使用,包括Apache DBCPHikariCP

【讨论】:

    猜你喜欢
    • 2017-06-04
    • 2011-01-26
    • 2021-09-01
    • 1970-01-01
    • 2016-12-10
    • 2014-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多