My application listens to few tables using Oracle UCP. In production environment application works fine, but In test environment, Application runs out of connection s from pool. I am closing and returning used connections in every query as well. Please refer the Connection close method.
public static synchronized void closeConnection(Connection con) throws Exception {
String print;
try {
if (con != null && !con.isClosed()) {
con.close();
con =null;
Config.DB_POOL_COUNT_AVAILABLE = pds.getAvailableConnectionsCount();
Config.DB_POOL_COUNT_BUSSY = pds.getBorrowedConnectionsCount();
Config.DB_POOL_COUNT_OPENED = Config.DB_POOL_COUNT_AVAILABLE + Config.DB_POOL_COUNT_BUSSY;
} else {
Config.DB_POOL_COUNT_AVAILABLE = pds.getAvailableConnectionsCount();
Config.DB_POOL_COUNT_BUSSY = pds.getBorrowedConnectionsCount();
Config.DB_POOL_COUNT_OPENED = Config.DB_POOL_COUNT_AVAILABLE + Config.DB_POOL_COUNT_BUSSY;
}
} catch (Exception e) {
Logger.errorLog(e);
} finally {
Config.DB_POOL_COUNT_AVAILABLE = pds.getAvailableConnectionsCount();
Config.DB_POOL_COUNT_BUSSY = pds.getBorrowedConnectionsCount();
Config.DB_POOL_COUNT_OPENED = Config.DB_POOL_COUNT_AVAILABLE + Config.DB_POOL_COUNT_BUSSY;
if(con != null && !con.isClosed()){
con.close();
con=null;
}
}
}