List of usage examples for org.apache.commons.dbcp PoolingDriver getPoolNames
public synchronized String[] getPoolNames()
From source file:com.evanmclean.evlib.commons.dbcp.DbcpUtils.java
/** * Close all DBCP pools./*w w w .j a v a 2 s . c om*/ */ public static void closePools() { final PoolingDriver driver = getPoolingDriver(); if (driver != null) { final String[] pns = driver.getPoolNames(); for (String pn : pns) try { final ObjectPool pool = driver.getConnectionPool(pn); if (pool != null) pool.clear(); } catch (Throwable ex) { // empty } } }
From source file:org.eclipse.osee.jdbc.internal.PoolFactory.java
public Map<String, String> getPoolStats() { Map<String, String> stats = new LinkedHashMap<String, String>(); PoolingDriver driver = poolingDriver.get(); stats.put("db.pool.driver", poolConfiguration.getPoolConnectionDriver()); String poolVersion = String.format("%s.%s", driver.getMajorVersion(), driver.getMinorVersion()); stats.put("db.pool.version", poolVersion); String[] names = driver.getPoolNames(); int count = 0; for (String name : names) { try {/* www.ja v a 2s .c o m*/ ObjectPool<?> pool = driver.getConnectionPool(name); stats.put(String.format("db.pool.%s.id", count), name); stats.put(String.format("db.pool.%s.active", count), String.valueOf(pool.getNumActive())); stats.put(String.format("db.pool.%s.idle", count), String.valueOf(pool.getNumIdle())); } catch (SQLException ex) { // Do Nothing } finally { count++; } } return stats; }
From source file:org.opencms.db.CmsDriverManager.java
/** * Destroys this driver manager and releases all allocated resources.<p> *//* w w w. ja v a 2 s . c o m*/ public void destroy() { try { if (m_projectDriver != null) { try { m_projectDriver.destroy(); } catch (Throwable t) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_PROJECT_DRIVER_0), t); } m_projectDriver = null; } if (m_userDriver != null) { try { m_userDriver.destroy(); } catch (Throwable t) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_USER_DRIVER_0), t); } m_userDriver = null; } if (m_vfsDriver != null) { try { m_vfsDriver.destroy(); } catch (Throwable t) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_VFS_DRIVER_0), t); } m_vfsDriver = null; } if (m_historyDriver != null) { try { m_historyDriver.destroy(); } catch (Throwable t) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_HISTORY_DRIVER_0), t); } m_historyDriver = null; } if (m_connectionPools != null) { for (int i = 0; i < m_connectionPools.size(); i++) { PoolingDriver driver = m_connectionPools.get(i); String[] pools = driver.getPoolNames(); for (int j = 0; j < pools.length; j++) { try { driver.closePool(pools[j]); if (CmsLog.INIT.isDebugEnabled()) { CmsLog.INIT.debug( Messages.get().getBundle().key(Messages.INIT_CLOSE_CONN_POOL_1, pools[j])); } } catch (Throwable t) { LOG.error( Messages.get().getBundle().key(Messages.LOG_CLOSE_CONN_POOL_ERROR_1, pools[j]), t); } } } m_connectionPools = null; } m_monitor.clearCache(); m_lockManager = null; m_htmlLinkValidator = null; } catch (Throwable t) { // ignore } if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( Messages.get().getBundle().key(Messages.INIT_DRIVER_MANAGER_DESTROY_1, getClass().getName())); } org.opencms.db.jpa.CmsSqlManager.destroy(); }