Varun
Varun

Reputation: 125

Connection Pooling is not working for DB2 database through UCP

We are writing a simple standalone java batch. We are using DB2 database. We are trying to do connection pooling using UCP (Version: ucp-11.2.0.3.0).

We have initialized minimum pool size as 5. But when we retrieve one connection and when we are printing the Available and Borrowed connections, we are getting Available as 0 and Borrowed as 1. When retrieving multiple connections, it is still printing the same eventhough the mimimum pool size is 5. we are not getting the any exception eventhough the max limit is crossed. Could you please help us on resolving the issue?

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

Upvotes: 0

Views: 1106

Answers (1)

Maksim Zinal
Maksim Zinal

Reputation: 86

UCP is the connection pooling library for Oracle Database. Db2 does not come with its own connection pooling library, instead, it works well with major connection pooling libraries, including Apache DBCP and HikariCP.

Upvotes: 0

Related Questions