public static void destroyDataSource ( DataSource dataSource , boolean force ) { synchronized ( dataSourcesStructureLock ) { String dsName = null ; for ( Map . Entry < String , DataSource > dsEntry : dataSources . entrySet ( ) ) { DataSource ds = dsEntry . getValue ( ) ; if ( ds == dataSource ) { dsName = dsEntry . getKey ( ) ; break ; } } if ( force || dsName != null ) { for ( Map . Entry < String , DataSourceProvider > dspEntry : dataSourceProviders . entrySet ( ) ) { // try them one by one String dspName = dspEntry . getKey ( ) ; DataSourceProvider dsp = dspEntry . getValue ( ) ; try { if ( dsp . destroyDataSource ( dataSource ) ) { if ( dsName != null ) { dataSources . remove ( dsName ) ; } break ; } } catch ( NoClassDefFoundError e ) { // ignore } catch ( Throwable e ) { log . error ( "Error when destroying data source '" + dsName + "' using provider '" + dspName + "'" , e ) ; } } } } }
Destroy a data source got from or created by ConnectionUtility before . If any exception occurred it will be logged but never propagated .