public void dispose() { super.dispose(); if (dataSource != null && dataSource instanceof ManageableDataSource) { try { ManageableDataSource mds = (ManageableDataSource) dataSource; mds.close(); } catch (SQLException e) { // it's ok, we did our best.. LOGGER.log(Level.FINE, "Could not close dataSource", e); } } // Store the exception for logging later if the object is used after disposal if (TRACE_ENABLED) { disposedBy = new RuntimeException( "DataSource disposed by thread " + Thread.currentThread().getName()); } dataSource = null; } /**
/** * Closes the mbtiles database connection. * * <p>The application should always call this method when done with a mbtiles to prevent * connection leakage. */ public void close() { if (dataStore != null) { dataStore.dispose(); } try { if (connPool instanceof BasicDataSource) { ((BasicDataSource) connPool).close(); } else if (connPool instanceof ManageableDataSource) { ((ManageableDataSource) connPool).close(); } } catch (SQLException e) { LOGGER.log(Level.WARNING, "Error closing database connection", e); } }
/** * Closes the geopackage database connection. * * <p>The application should always call this method when done with a geopackage to prevent * connection leakage. */ public void close() { if (dataStore != null) { dataStore.dispose(); } try { if (connPool instanceof BasicDataSource) { ((BasicDataSource) connPool).close(); } else if (connPool instanceof ManageableDataSource) { ((ManageableDataSource) connPool).close(); } } catch (SQLException e) { LOGGER.log(Level.WARNING, "Error closing database connection", e); } }
public void tearDown() throws Exception { final String leakMessage = "Expected no active connection, either there is a connection leak " + "or you forgot to close some object holding onto connections in the tests (e.g., a reader, an iterator)"; if (dataSource instanceof BasicDataSource) { BasicDataSource bds = (BasicDataSource) dataSource; assertEquals(leakMessage, 0, bds.getNumActive()); } else if (dataSource instanceof DBCPDataSource) { BasicDataSource bds = (BasicDataSource) ((DBCPDataSource) dataSource).getWrapped(); assertEquals(leakMessage, 0, bds.getNumActive()); } if (dataSource instanceof BasicDataSource) { BasicDataSource bds = (BasicDataSource) dataSource; bds.close(); } else if (dataSource instanceof ManageableDataSource) { ((ManageableDataSource) dataSource).close(); } }
public void dispose() { if(dataSource != null && dataSource instanceof ManageableDataSource) { try { ManageableDataSource mds = (ManageableDataSource) dataSource; dataSource = null; mds.close(); } catch(SQLException e) { // it's ok, we did our best.. LOGGER.log(Level.FINE, "Could not close dataSource", e); } } } }
public void dispose() { if(dataSource != null && dataSource instanceof ManageableDataSource) { try { ManageableDataSource mds = (ManageableDataSource) dataSource; dataSource = null; mds.close(); } catch(SQLException e) { // it's ok, we did our best.. LOGGER.log(Level.FINE, "Could not close dataSource", e); } } } }
public void dispose() { if(dataSource != null && dataSource instanceof ManageableDataSource) { try { ManageableDataSource mds = (ManageableDataSource) dataSource; mds.close(); } catch(SQLException e) { // it's ok, we did our best.. LOGGER.log(Level.FINE, "Could not close dataSource", e); } } dataSource = null; } /**
/** * Closes the geopackage database connection. * * <p>The application should always call this method when done with a geopackage to prevent * connection leakage. */ public void close() { if (dataStore != null) { dataStore.dispose(); } try { if (connPool instanceof BasicDataSource) { ((BasicDataSource) connPool).close(); } else if (connPool instanceof ManageableDataSource) { ((ManageableDataSource) connPool).close(); } } catch (SQLException e) { LOGGER.log(Level.WARNING, "Error closing database connection", e); } }
/** * Closes the mbtiles database connection. * * <p>The application should always call this method when done with a mbtiles to prevent * connection leakage. */ public void close() { if (dataStore != null) { dataStore.dispose(); } try { if (connPool instanceof BasicDataSource) { ((BasicDataSource) connPool).close(); } else if (connPool instanceof ManageableDataSource) { ((ManageableDataSource) connPool).close(); } } catch (SQLException e) { LOGGER.log(Level.WARNING, "Error closing database connection", e); } }