protected void finalize() throws Throwable { if (dataSource != null) { LOGGER.severe( "There's code using JDBC based datastore and " + "not disposing them. This may lead to temporary loss of database connections. " + "Please make sure all data access code calls DataStore.dispose() " + "before freeing all references to it"); dispose(); } }
/** * 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); } }
protected void disconnect() throws Exception { setup.tearDown(); dataStore.dispose(); }
@After public void tearDown() { dataStore.getLogger().removeHandler(mockLogHandler); dataStore.dispose(); }
/** Returns a properly initialized connection. It's up to the calling code to close it */ protected Connection getConnection() throws SQLException, IOException { Connection conn = getDataSource().getConnection(); JDBCDataStore store = null; try { store = new JDBCDataStore(); createDataStoreFactory().createSQLDialect(store).initializeConnection(conn); } finally { if (store != null) { store.dispose(); } } return conn; }
public void testJNDIDataSource() throws Exception { ((JDBCJNDITestSetup) setup).setupJNDIEnvironment(getDataStoreFactory()); HashMap params = new HashMap(); String dbtype = setup.createDataStoreFactory().getDatabaseID(); params.put(JDBCDataStoreFactory.NAMESPACE.key, "http://www.geotools.org/test"); params.put(JDBCDataStoreFactory.DBTYPE.key, dbtype); params.put(JDBCJNDIDataStoreFactory.JNDI_REFNAME.key, "ds"); JDBCDataStore dataStore = null; try { dataStore = (JDBCDataStore) DataStoreFinder.getDataStore(params); try (Connection con = dataStore.getDataSource().getConnection()) { assertTrue(con != null); assertFalse(con.isClosed()); } } finally { if (dataStore != null) { dataStore.dispose(); } } }
protected void finalize() throws Throwable { if(dataSource != null) { LOGGER.severe("There's code using JDBC based datastore and " + "not disposing them. This may lead to temporary loss of database connections. " + "Please make sure all data access code calls DataStore.dispose() " + "before freeing all references to it"); dispose(); } }
protected void finalize() throws Throwable { if(dataSource != null) { LOGGER.severe("There's code using JDBC based datastore and " + "not disposing them. This may lead to temporary loss of database connections. " + "Please make sure all data access code calls DataStore.dispose() " + "before freeing all references to it"); dispose(); } }
/** * 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); } }
@AfterClass public static void tearDownStore() { osAccess.dispose(); h2.dispose(); }
store.dispose();