Program: 84261
Project: 84261
Buggy source:
/** 
 * This method will check the database ChangeLog table used to keep track of the changes in the file. If the table does not exist it will create one otherwise it will not do anything besides outputting a log message.
 */
public void checkDatabaseChangeLogTable(Migrator migrator) throws JDBCException, IOException {
  Statement statement=null;
  Connection connection=getConnection();
  ResultSet checkTableRS=null;
  ResultSet checkColumnsRS=null;
  List<String> statementsToExecute=new ArrayList<String>();
  boolean wroteToOutput=false;
  try {
    checkTableRS=connection.getMetaData().getTables(getCatalogName(),getSchemaName(),getDatabaseChangeLogTableName(),new String[]{"String_Node_Str"});
    if (checkTableRS.next()) {
      changeLogTableExists=true;
      checkColumnsRS=connection.getMetaData().getColumns(getCatalogName(),getSchemaName(),getDatabaseChangeLogTableName(),null);
      boolean hasDescription=false;
      boolean hasComments=false;
      boolean hasTag=false;
      boolean hasLiquibase=false;
      while (checkColumnsRS.next()) {
        String columnName=checkColumnsRS.getString("String_Node_Str");
        if ("String_Node_Str".equalsIgnoreCase(columnName)) {
          hasDescription=true;
        }
 else         if ("String_Node_Str".equalsIgnoreCase(columnName)) {
          hasComments=true;
        }
 else         if ("String_Node_Str".equalsIgnoreCase(columnName)) {
          hasTag=true;
        }
 else         if ("String_Node_Str".equalsIgnoreCase(columnName)) {
          hasLiquibase=true;
        }
      }
      if (!hasDescription) {
        statementsToExecute.add("String_Node_Str");
      }
      if (!hasTag) {
        statementsToExecute.add("String_Node_Str");
      }
      if (!hasComments) {
        statementsToExecute.add("String_Node_Str");
      }
      if (!hasLiquibase) {
        statementsToExecute.add("String_Node_Str");
      }
    }
 else     if (!changeLogCreateAttempted) {
      changeLogCreateAttempted=true;
      String createTableStatement=getCreateChangeLogSQL();
      if (!canCreateChangeLogTable()) {
        throw new JDBCException("String_Node_Str" + "String_Node_Str" + createTableStatement);
      }
      statementsToExecute.add(createTableStatement);
      if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
        log.info("String_Node_Str");
        changeLogTableExists=true;
      }
    }
    for (    String sql : statementsToExecute) {
      if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
        statement=connection.createStatement();
        statement.executeUpdate(sql);
        connection.commit();
      }
 else {
        if (!migrator.getMode().equals(Migrator.Mode.OUTPUT_FUTURE_ROLLBACK_SQL_MODE)) {
          migrator.getOutputSQLWriter().append(sql).append("String_Node_Str").append(StreamUtil.getLineSeparator());
          wroteToOutput=true;
        }
      }
    }
    if (wroteToOutput) {
      migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
    }
  }
 catch (  SQLException e) {
    throw new JDBCException(e);
  }
 finally {
    if (statement != null) {
      try {
        statement.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
    if (checkTableRS != null) {
      try {
        checkTableRS.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
    if (checkColumnsRS != null) {
      try {
        checkColumnsRS.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * This method will check the database ChangeLog table used to keep track of the changes in the file. If the table does not exist it will create one otherwise it will not do anything besides outputting a log message.
 */
public void checkDatabaseChangeLogTable(Migrator migrator) throws JDBCException, IOException {
  Statement statement=null;
  Connection connection=getConnection();
  ResultSet checkTableRS=null;
  ResultSet checkColumnsRS=null;
  List<String> statementsToExecute=new ArrayList<String>();
  boolean wroteToOutput=false;
  try {
    checkTableRS=connection.getMetaData().getTables(getCatalogName(),getSchemaName(),getDatabaseChangeLogTableName(),new String[]{"String_Node_Str"});
    if (checkTableRS.next()) {
      changeLogTableExists=true;
      checkColumnsRS=connection.getMetaData().getColumns(getCatalogName(),getSchemaName(),getDatabaseChangeLogTableName(),null);
      boolean hasDescription=false;
      boolean hasComments=false;
      boolean hasTag=false;
      boolean hasLiquibase=false;
      while (checkColumnsRS.next()) {
        String columnName=checkColumnsRS.getString("String_Node_Str");
        if ("String_Node_Str".equalsIgnoreCase(columnName)) {
          hasDescription=true;
        }
 else         if ("String_Node_Str".equalsIgnoreCase(columnName)) {
          hasComments=true;
        }
 else         if ("String_Node_Str".equalsIgnoreCase(columnName)) {
          hasTag=true;
        }
 else         if ("String_Node_Str".equalsIgnoreCase(columnName)) {
          hasLiquibase=true;
        }
      }
      if (!hasDescription) {
        statementsToExecute.add("String_Node_Str");
      }
      if (!hasTag) {
        statementsToExecute.add("String_Node_Str");
      }
      if (!hasComments) {
        statementsToExecute.add("String_Node_Str");
      }
      if (!hasLiquibase) {
        statementsToExecute.add("String_Node_Str");
      }
    }
 else     if (!changeLogCreateAttempted) {
      changeLogCreateAttempted=true;
      String createTableStatement=getCreateChangeLogSQL();
      if (!canCreateChangeLogTable()) {
        throw new JDBCException("String_Node_Str" + "String_Node_Str" + createTableStatement);
      }
      statementsToExecute.add(createTableStatement);
      if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
        log.info("String_Node_Str");
        changeLogTableExists=true;
      }
    }
    for (    String sql : statementsToExecute) {
      if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
        statement=connection.createStatement();
        statement.executeUpdate(sql);
        connection.commit();
      }
 else {
        if (!migrator.getMode().equals(Migrator.Mode.OUTPUT_FUTURE_ROLLBACK_SQL_MODE)) {
          Writer writer=migrator.getOutputSQLWriter();
          if (writer == null) {
            wroteToOutput=false;
          }
 else {
            writer.append(sql).append("String_Node_Str").append(StreamUtil.getLineSeparator());
            wroteToOutput=true;
          }
        }
      }
    }
    if (wroteToOutput) {
      migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
    }
  }
 catch (  SQLException e) {
    throw new JDBCException(e);
  }
 finally {
    if (statement != null) {
      try {
        statement.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
    if (checkTableRS != null) {
      try {
        checkTableRS.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
    if (checkColumnsRS != null) {
      try {
        checkColumnsRS.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
  }
}