@Override
  public void close() throws DatabaseException {
    DatabaseConnection connection = getConnection();
    if (connection != null) {
      if (previousAutoCommit != null) {
        try {
          connection.setAutoCommit(previousAutoCommit);
        } catch (DatabaseException e) {
          LogFactory.getLogger()
              .warning("Failed to restore the auto commit to " + previousAutoCommit);

          throw e;
        }
      }
      connection.close();
    }
    ExecutorService.getInstance().clearExecutor(this);
  }