Program: 84270
Project: 84270
Buggy source:
/** 
 * This method will check the database ChangeLogLock table used to keep track of if a machine is updating the database. If the table does not exist it will create one otherwise it will not do anything besides outputting a log message.
 */
public void checkDatabaseChangeLogLockTable(Migrator migrator) throws JDBCException, IOException {
  Statement statement=null;
  Connection connection=getConnection();
  ResultSet rs=null;
  changeLogLockTableExists=true;
  try {
    rs=connection.getMetaData().getTables(getCatalogName(),getSchemaName(),getDatabaseChangeLogLockTableName(),new String[]{"String_Node_Str"});
    if (!rs.next()) {
      String createTableStatement=getCreateChangeLogLockSQL();
      if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
        statement=connection.createStatement();
        statement.executeUpdate(createTableStatement);
        connection.commit();
        log.info("String_Node_Str");
      }
 else {
        if (!migrator.getMode().equals(Migrator.Mode.OUTPUT_FUTURE_ROLLBACK_SQL_MODE)) {
          if (!outputtedLockWarning) {
            migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator());
            migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator());
            migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator());
            migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator());
            migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + getCreateChangeLogLockSQL()+ "String_Node_Str"+ StreamUtil.getLineSeparator());
            migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + getChangeLogLockInsertSQL()+ "String_Node_Str"+ StreamUtil.getLineSeparator());
            migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator()+ StreamUtil.getLineSeparator());
            outputtedLockWarning=true;
          }
          migrator.getOutputSQLWriter().append(createTableStatement);
          migrator.getOutputSQLWriter().append("String_Node_Str");
          migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
          migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
        }
        changeLogLockTableExists=false;
      }
    }
    rs.close();
    if (statement != null) {
      statement.close();
    }
    String insertRowStatment=getChangeLogLockInsertSQL();
    if (changeLogLockTableExists) {
      statement=connection.createStatement();
      rs=statement.executeQuery("String_Node_Str".toUpperCase());
      if (!rs.next()) {
        if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
          statement=connection.createStatement();
          statement.executeUpdate(insertRowStatment);
          connection.commit();
          log.info("String_Node_Str");
        }
 else {
          migrator.getOutputSQLWriter().append(insertRowStatment);
          migrator.getOutputSQLWriter().append("String_Node_Str");
          migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
          migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
        }
        rs.close();
      }
    }
 else {
      if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
        throw new JDBCException("String_Node_Str");
      }
 else {
        migrator.getOutputSQLWriter().append(insertRowStatment);
        migrator.getOutputSQLWriter().append("String_Node_Str");
        migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
        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 (rs != null) {
      try {
        rs.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * This method will check the database ChangeLogLock table used to keep track of if a machine is updating the database. If the table does not exist it will create one otherwise it will not do anything besides outputting a log message.
 */
public void checkDatabaseChangeLogLockTable(Migrator migrator) throws JDBCException, IOException {
  Statement statement=null;
  Connection connection=getConnection();
  ResultSet rs=null;
  try {
    rs=connection.getMetaData().getTables(getCatalogName(),getSchemaName(),getDatabaseChangeLogLockTableName(),new String[]{"String_Node_Str"});
    if (!rs.next()) {
      if (!changeLogLockCreateAttempted) {
        changeLogLockCreateAttempted=true;
        String createTableStatement=getCreateChangeLogLockSQL();
        if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
          statement=connection.createStatement();
          statement.executeUpdate(createTableStatement);
          connection.commit();
          log.info("String_Node_Str");
          changeLogLockTableExists=true;
        }
 else {
          if (!migrator.getMode().equals(Migrator.Mode.OUTPUT_FUTURE_ROLLBACK_SQL_MODE)) {
            if (!outputtedLockWarning) {
              migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator());
              migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator());
              migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator());
              migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator());
              migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + getCreateChangeLogLockSQL()+ "String_Node_Str"+ StreamUtil.getLineSeparator());
              migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + getChangeLogLockInsertSQL()+ "String_Node_Str"+ StreamUtil.getLineSeparator());
              migrator.getOutputSQLWriter().write(migrator.getDatabase().getLineComment() + "String_Node_Str" + StreamUtil.getLineSeparator()+ StreamUtil.getLineSeparator());
              outputtedLockWarning=true;
            }
            migrator.getOutputSQLWriter().append(createTableStatement);
            migrator.getOutputSQLWriter().append("String_Node_Str");
            migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
            migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
          }
        }
      }
    }
 else {
      changeLogLockTableExists=true;
    }
    rs.close();
    if (statement != null) {
      statement.close();
    }
    String insertRowStatment=getChangeLogLockInsertSQL();
    if (changeLogLockTableExists) {
      statement=connection.createStatement();
      rs=statement.executeQuery("String_Node_Str".toUpperCase());
      if (!rs.next()) {
        if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
          statement=connection.createStatement();
          statement.executeUpdate(insertRowStatment);
          connection.commit();
          log.info("String_Node_Str");
        }
 else {
          migrator.getOutputSQLWriter().append(insertRowStatment);
          migrator.getOutputSQLWriter().append("String_Node_Str");
          migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
          migrator.getOutputSQLWriter().append(StreamUtil.getLineSeparator());
        }
        rs.close();
      }
    }
 else {
      if (migrator.getMode().equals(Migrator.Mode.EXECUTE_MODE)) {
        throw new JDBCException("String_Node_Str");
      }
    }
  }
 catch (  SQLException e) {
    throw new JDBCException(e);
  }
 finally {
    if (statement != null) {
      try {
        statement.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
    if (rs != null) {
      try {
        rs.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
  }
}