Cleanly shuts down all databases in the provided environment.

@throws IOException if a database delete attempt failed.
@throws DatabaseException if an error occurs while closing the class
catalog database.
354901
void shutdown() throws IOException {
        synchronized (this) {
            for (BdbEnvironmentInfo envInfo : this.envInfos) {
                try {
                    envInfo.getClassCatalog().close();
                } catch (DatabaseException ignore) {
                    LOGGER.log(Level.SEVERE, "Failure closing class catalog", ignore);
                }
                envInfo.closeAndRemoveAllDatabaseHandles();
                
                try (Environment env = envInfo.getEnvironment()) {
                    if (this.deleteOnExit) {
                        FileUtil.deleteDirectory(env.getHome());
                    }
                }
            }
            this.envInfos.clear();
        }
    }
684520
@Override
    public void shutdown() {
        synchronized (connections) {
            parent.channelCloses(this);
            for (final MessageInbound connection : connections) {
                try {
                    connection.getWsOutbound().close(0, null);
                } catch (final IOException e) {
                    LOG.error("Connection [" + connection.toString() + "] can't be closed.", e);
                } finally {
                    final ExecutorService executorService = connectionThreads.get(connection);
                    if (executorService != null) {
                        executorService.shutdown();
                    }
                    connectionThreads.remove(connection);
                }
            }
            connections.clear();
        }
        callback = null;
    }
413021
protected void closeAllConnections(String databasename)
  {
    String sql
      = "SELECT pg_terminate_backend(pg_stat_activity.pid)\n"
      + "FROM pg_stat_activity\n"
      + "WHERE pg_stat_activity.datname = ?\n"
      + "  AND pid <> pg_backend_pid();";
    try(Connection conn = getDataSource().getConnection())
    {
      DatabaseMetaData meta = conn.getMetaData();
      
      if(meta.getDatabaseMajorVersion() == 9 
        && meta.getDatabaseMinorVersion() <= 1)
      {
        sql
          = "SELECT pg_terminate_backend(pg_stat_activity.procpid)\n"
          + "FROM pg_stat_activity\n"
          + "WHERE pg_stat_activity.datname = ?\n"
          + "  AND procpid <> pg_backend_pid();";
      }
    }
    catch(SQLException ex)
    {
      log.warn("Could not get the PostgreSQL version", ex);
    }
    
    getJdbcTemplate().queryForRowSet(sql, databasename);

  }
864301
@Override
    public void close() throws Exception {
        unbindAll();
        initialContext.destroySubcontext("java:/comp/env/jdbc");
        initialContext.destroySubcontext("java:/comp/env");
        initialContext.destroySubcontext("java:/comp");
        initialContext.destroySubcontext("java:");
        initialContext.close();
    }
1350364
public static void closeDatabases(int mode) {

        // A VoltDB extension to work around ENG-6044
        /* disable 1 line ...
        Iterator it = databaseIDMap.values().iterator();
           ... disabled 1 line */
        java.util.Iterator<Database> it = databaseIDMap.values().iterator();
        // End of VoltDB extension

        while (it.hasNext()) {
            Database db = (Database) it.next();

            try {
                db.close(mode);
            } catch (HsqlException e) {}
        }
    }
834357
public void close() throws SQLException {

        validate();

        try {
            this.connection.rollback();
            this.connection.clearWarnings();
            this.connectionDefaults.setDefaults(this.connection);
            this.connection.reset();
            fireCloseEvent();
        } catch (SQLException e) {
            fireSqlExceptionEvent(e);

            throw e;
        }
    }
38791
@Override
  public void close() throws SQLException
  {
    logger.debug(" public void close()");

    if (isClosed)
    {
      // No exception is raised even if the connection is closed.
      return;
    }

    isClosed = true;
    try
    {
      if (sfSession != null)
      {
        sfSession.close();
        sfSession = null;
      }

      // make sure to close all created statements
      synchronized (openStatements)
      {
        for (Statement stmt : openStatements)
        {
          if (stmt != null && !stmt.isClosed())
          {
            if (stmt.isWrapperFor(SnowflakeStatementV1.class))
            {
              stmt.unwrap(SnowflakeStatementV1.class).close(false);
            }
            else
            {
              stmt.close();
            }
          }
        }
        openStatements.clear();
      }
    }
    catch (SFException ex)
    {
      throw new SnowflakeSQLException(
          ex.getCause(), ex.getSqlState(), ex.getVendorCode(), ex.getParams());
    }
  }
688131
public synchronized void shutdown() {
		if (instances.size() > 0) {
			OLogManager.instance().debug(null,
					"Found %d databases opened during OrientDB shutdown. Assure to always close database instances after usage",
					instances.size());

			for (ODatabaseComplex<?> db : new HashSet<ODatabaseComplex<?>>(instances.keySet())) {
				if (db != null && !db.isClosed()) {
					db.close();
				}
			}
		}
	}
1243343
@Override
    public void deleteAll() throws LockingException {
        Connection conn = null;
        Statement stmnt = null;
        try {
            String sql = "DELETE FROM " + LOCK_TABLE;
            if (log.isDebugEnabled()) log.debug("RDBMEntityLockStore.deleteAll(): " + sql);

            conn = RDBMServices.getConnection();
            try {
                stmnt = conn.createStatement();
                int rc = stmnt.executeUpdate(sql);
                if (log.isDebugEnabled()) {
                    String msg = "Deleted " + rc + " locks.";
                    log.debug("RDBMEntityLockStore.deleteAll(): " + msg);
                }
            } finally {
                if (stmnt != null) stmnt.close();
            }
        } catch (SQLException sqle) {
            throw new LockingException("Problem deleting locks", sqle);
        } finally {
            RDBMServices.releaseConnection(conn);
        }
    }
407010
public void shutdown() {
        // If shutdown has already been called then we don't need to shutdown again
        if (acceptTasks.getAndSet(false)) {
            //pass straight to queue, tasks passed via submitTaskToQueue will now be blocked.
            Future<?> close = queue.submit(new Runnable() {
                @Override
                public void run() {
                    db.close();
                }
            });
            queue.shutdown();
            try {
                close.get();
                queue.awaitTermination(5, TimeUnit.MINUTES);
            } catch (InterruptedException e) {
                logger.log(Level.SEVERE, "Interrupted while waiting for queue to terminate", e);
            } catch (ExecutionException e) {
                logger.log(Level.SEVERE, "Failed to close database", e);
            }
        } else {
            logger.log(Level.WARNING, "Database is already closed.");
        }
    }
1199413
def close(self, silent=False):
        
        if not silent:
            saveme = get_input("Save database contents to '{}/'? (y, [n]) \n"
                               "To save elsewhere, run db.save() before closing. ".format(self.directory))
            if saveme.lower() == 'y':
                self.save()

            delete = get_input("Do you want to delete {0}? (y,[n]) \n"
                               "Don't worry, a new one will be generated if you run astrodb.Database('{1}') "
                               .format(self.dbpath, self.sqlpath))
            if delete.lower() == 'y':
                print("Deleting {}".format(self.dbpath))
                os.system("rm {}".format(self.dbpath))

        print('Closing connection')
        self.conn.close()
1342126
def close_database_session(session):
    """"""

    try:
        session.close()
    except OperationalError as e:
        raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0])
801602
private void shutDownSqlDrivers() {

        // This manually deregisters JDBC driver, which prevents Tomcat 7 from complaining about memory leaks
        Enumeration<Driver> drivers = DriverManager.getDrivers();
        while (drivers.hasMoreElements()) {
            Driver driver = drivers.nextElement();
            try {
                DriverManager.deregisterDriver(driver);
            } catch (Throwable e) {
                System.out.println(
                    Messages.get().getBundle().key(
                        Messages.ERR_DEREGISTERING_JDBC_DRIVER_1,
                        driver.getClass().getName()));
                e.printStackTrace(System.out);
            }
        }

        try {
            Class<?> cls = Class.forName("com.mysql.jdbc.AbandonedConnectionCleanupThread");
            Method shutdownMethod = (cls == null ? null : cls.getMethod("shutdown"));
            if (shutdownMethod != null) {
                shutdownMethod.invoke(null);
            }
        } catch (Throwable e) {
            System.out.println("Failed to shutdown MySQL connection cleanup thread: " + e.getMessage());
        }
    }
839187
@Override
	public void shutdown() {
		if (collection != null) {
			try {
				collection.shutdown();
			} catch (IOException e) {
				LOGGER.severe("FAILED collection shutdown" + e.getMessage());
			}
		}
		if (exclusionFactory != null) {
			exclusionFactory.shutdown();
		}
	}
486601
final void closeAndRemoveAllDatabaseHandles() {
        for (Database databaseHandle : this.databaseHandles) {
            try {
                databaseHandle.close();
            } catch (EnvironmentFailureException | IllegalStateException ex) {
                LOGGER.log(Level.SEVERE,
                        "Error closing databases", ex);
            }
        }
        this.databaseHandles.clear();
    }
450783
public function deleteAll()
    {
        $schema = $this->getConn()->getSchemaManager();
        foreach ($schema->databaseList() as $dbName) {
            if ($this->isDBTemp($dbName)) {
                $schema->dropDatabase($dbName);
                $schema->alterationMessage("Dropped database \"$dbName\"", 'deleted');
                flush();
            }
        }
    }
497328
public void delete() throws DocumentStoreNotDeletedException {
        try {
            this.close();
        } catch (Exception e) {
            // caught exception could be something benign like DocumentStore already closed, so just log
            logger.log(Level.WARNING, "Caught exception whilst closing DocumentStore in delete()", e);
        }
        if (!location.exists()) {
            String msg = String.format("DocumentStore %s doesn't exist on disk", location);
            logger.warning(msg);
            throw new DocumentStoreNotDeletedException(msg);
        } else {
            try {
                FileUtils.deleteDirectory(location);
            } catch (IOException ioe) {
                String msg = String.format("DocumentStore %s not deleted", location);
                logger.log(Level.WARNING, msg, ioe);
                throw new DocumentStoreNotDeletedException(msg, ioe);
            }
            eventBus.post(new DocumentStoreDeleted(databaseName));
        }
    }