Example usage for org.apache.commons.dbcp.datasources PerUserPoolDataSource close

List of usage examples for org.apache.commons.dbcp.datasources PerUserPoolDataSource close

Introduction

In this page you can find the example usage for org.apache.commons.dbcp.datasources PerUserPoolDataSource close.

Prototype

public void close() 

Source Link

Document

Close pool(s) being maintained by this datasource.

Usage

From source file:org.wsm.database.tools.util.BaseLoadTestConnectionManager.java

public static synchronized void removeConnectionPoolDataSourceFromBucket(String keyName) {
    log.debug("Removing Connection Pool DataSource from the Bucket");
    if (connectionPoolDataSourceBucket != null) {
        if (!EmptyOrNullStringValidator.isEmpty(keyName)) {
            Object dsObj = connectionPoolDataSourceBucket.get(keyName);
            if (dsObj != null) {
                if (dsObj instanceof PerUserPoolDataSource) {
                    log.debug("DataSource type is PerUserPoolDataSource");
                    PerUserPoolDataSource pupdsTemp = (PerUserPoolDataSource) dsObj;
                    pupdsTemp.close();
                    log.debug("Closed DataSource");
                }/*www .  jav a  2s.  c  o m*/
                if (dsObj instanceof PoolingDataSource) {
                    log.debug("DataSource type is PoolingDataSource");
                    /*                        PoolingDataSource pds = (PoolingDataSource) dsObj;
                            
                                            pds = null;
                    */ log.debug("Set the Object to null");
                }
                if (dsObj instanceof BasicDataSource) {
                    log.debug("DataSource type is PoolingDataSource");
                    BasicDataSource bds = (BasicDataSource) dsObj;
                    try {
                        bds.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                    log.debug("Closed DataSource");
                }
            }
        }
    }
    if (!EmptyOrNullStringValidator.isEmpty(keyName)) {
        if (connectionPoolDataSourceBucket != null) {
            connectionPoolDataSourceBucket.remove(keyName);
            log.debug("Removed the DataSource object from the Bucket.");
        }
    }
}