Program: 114783
Project: 114783
Buggy source:
/** 
 * This method is used to remove the FK constraint which is unnamed This finds the name of the constraint and build the query to delete the constraint and execute it
 * @param sqlScriptPath path of sql script
 * @throws SQLException
 */
protected void dropFKConstraint(String sqlScriptPath) throws SQLException {
  Connection connection=null;
  PreparedStatement preparedStatement=null;
  ResultSet resultSet=null;
  Statement statement=null;
  try {
    String queryToExecute=IOUtils.toString(new FileInputStream(new File(sqlScriptPath + "String_Node_Str")),"String_Node_Str");
    String queryArray[]=queryToExecute.split(Constants.LINE_BREAK);
    connection=APIMgtDBUtil.getConnection();
    String dbType=MigrationDBCreator.getDatabaseType(connection);
    connection.setAutoCommit(false);
    statement=connection.createStatement();
    if (Constants.DB_TYPE_ORACLE.equals(dbType)) {
      queryArray[0]=queryArray[0].replace(Constants.DELIMITER,"String_Node_Str");
    }
    resultSet=statement.executeQuery(queryArray[0]);
    String constraintName=null;
    while (resultSet.next()) {
      constraintName=resultSet.getString("String_Node_Str");
    }
    if (constraintName != null) {
      queryToExecute=queryArray[1].replace("String_Node_Str",constraintName);
      if (Constants.DB_TYPE_ORACLE.equals(dbType)) {
        queryToExecute=queryToExecute.replace(Constants.DELIMITER,"String_Node_Str");
      }
      if (queryToExecute.contains("String_Node_Str")) {
        queryToExecute=queryToExecute.replace("String_Node_Str","String_Node_Str");
      }
      preparedStatement=connection.prepareStatement(queryToExecute);
      preparedStatement.execute();
      connection.commit();
    }
  }
 catch (  APIMigrationException e) {
    log.error("String_Node_Str",e);
  }
catch (  IOException e) {
    log.error("String_Node_Str",e);
  }
catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
 finally {
    if (statement != null) {
      try {
        statement.close();
      }
 catch (      SQLException e) {
        log.error("String_Node_Str",e);
      }
    }
    APIMgtDBUtil.closeAllConnections(preparedStatement,connection,resultSet);
  }
}

Fixed version (ground truth):
/** 
 * This method is used to remove the FK constraint which is unnamed This finds the name of the constraint and build the query to delete the constraint and execute it
 * @param sqlScriptPath path of sql script
 * @throws SQLException
 */
protected void dropFKConstraint(String sqlScriptPath) throws SQLException {
  Connection connection=null;
  PreparedStatement preparedStatement=null;
  ResultSet resultSet=null;
  Statement statement=null;
  try {
    connection=APIMgtDBUtil.getConnection();
    String dbType=MigrationDBCreator.getDatabaseType(connection);
    String queryToExecute=IOUtils.toString(new FileInputStream(new File(sqlScriptPath + "String_Node_Str" + File.separator+ dbType+ "String_Node_Str")),"String_Node_Str");
    String queryArray[]=queryToExecute.split(Constants.LINE_BREAK);
    connection.setAutoCommit(false);
    statement=connection.createStatement();
    if (Constants.DB_TYPE_ORACLE.equals(dbType)) {
      queryArray[0]=queryArray[0].replace(Constants.DELIMITER,"String_Node_Str");
      queryArray[0]=queryArray[0].replace("String_Node_Str",connection.getMetaData().getUserName());
    }
    resultSet=statement.executeQuery(queryArray[0]);
    String constraintName=null;
    while (resultSet.next()) {
      constraintName=resultSet.getString("String_Node_Str");
    }
    if (constraintName != null) {
      queryToExecute=queryArray[1].replace("String_Node_Str",constraintName);
      if (Constants.DB_TYPE_ORACLE.equals(dbType)) {
        queryToExecute=queryToExecute.replace(Constants.DELIMITER,"String_Node_Str");
      }
      if (queryToExecute.contains("String_Node_Str")) {
        queryToExecute=queryToExecute.replace("String_Node_Str","String_Node_Str");
      }
      preparedStatement=connection.prepareStatement(queryToExecute);
      preparedStatement.execute();
      connection.commit();
    }
  }
 catch (  APIMigrationException e) {
    log.error("String_Node_Str",e);
  }
catch (  IOException e) {
    log.error("String_Node_Str",e);
  }
catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
 finally {
    if (statement != null) {
      try {
        statement.close();
      }
 catch (      SQLException e) {
        log.error("String_Node_Str",e);
      }
    }
    APIMgtDBUtil.closeAllConnections(preparedStatement,connection,resultSet);
  }
}