@Override
  public void setConnection(final DatabaseConnection conn) {
    LogFactory.getLogger()
        .debug("Connected to " + conn.getConnectionUserName() + "@" + conn.getURL());
    this.connection = conn;
    try {
      boolean autoCommit = conn.getAutoCommit();
      if (autoCommit == getAutoCommitMode()) {
        // Don't adjust the auto-commit mode if it's already what the database wants it to be.
        LogFactory.getLogger()
            .debug("Not adjusting the auto commit mode; it is already " + autoCommit);
      } else {
        // Store the previous auto-commit mode, because the connection needs to be restored to it
        // when this
        // AbstractDatabase type is closed. This is important for systems which use connection
        // pools.
        previousAutoCommit = autoCommit;

        LogFactory.getLogger()
            .debug("Setting auto commit to " + getAutoCommitMode() + " from " + autoCommit);
        connection.setAutoCommit(getAutoCommitMode());
      }
    } catch (DatabaseException e) {
      LogFactory.getLogger()
          .warning("Cannot set auto commit to " + getAutoCommitMode() + " on connection");
    }

    this.connection.attached(this);
  }
 /**
  * Default implementation, just look for "local" IPs. If the database returns a null URL we return
  * false since we don't know it's safe to run the update.
  *
  * @throws liquibase.exception.DatabaseException
  */
 @Override
 public boolean isSafeToRunUpdate() throws DatabaseException {
   DatabaseConnection connection = getConnection();
   if (connection == null) {
     return true;
   }
   String url = connection.getURL();
   if (url == null) {
     return false;
   }
   return (url.contains("localhost")) || (url.contains("127.0.0.1"));
 }