Program: 114786
Project: 114786
Buggy source:
protected void updateAPIManagerDatabase(String sqlScriptPath) throws SQLException {
  log.info("String_Node_Str");
  Connection connection=null;
  PreparedStatement preparedStatement=null;
  Statement statement=null;
  ResultSet resultSet=null;
  try {
    connection=APIMgtDBUtil.getConnection();
    connection.setAutoCommit(false);
    String dbType=MigrationDBCreator.getDatabaseType(connection);
    if (Constants.DB_TYPE_MYSQL.equals(dbType)) {
      statement=connection.createStatement();
      resultSet=statement.executeQuery(GET_MYSQL_SESSION_MODE);
      if (resultSet.next()) {
        String mode=resultSet.getString("String_Node_Str");
        log.info("String_Node_Str" + mode);
        if (mode.contains(NO_ZERO_DATE_MODE)) {
          File timeStampFixScript=new File(sqlScriptPath + dbType + "String_Node_Str");
          if (timeStampFixScript.exists()) {
            log.info(NO_ZERO_DATE_MODE + "String_Node_Str");
            InputStream is=new FileInputStream(timeStampFixScript);
            List<String> sqlStatements=readSQLStatements(is,dbType);
            for (            String sqlStatement : sqlStatements) {
              preparedStatement=connection.prepareStatement(sqlStatement);
              preparedStatement.execute();
              connection.commit();
            }
          }
        }
      }
    }
    InputStream is=new FileInputStream(sqlScriptPath + dbType + "String_Node_Str");
    List<String> sqlStatements=readSQLStatements(is,dbType);
    for (    String sqlStatement : sqlStatements) {
      log.debug("String_Node_Str" + sqlStatement);
      if (Constants.DB_TYPE_ORACLE.equals(dbType)) {
        statement=connection.createStatement();
        statement.executeQuery(sqlStatement);
      }
 else {
        preparedStatement=connection.prepareStatement(sqlStatement);
        preparedStatement.execute();
      }
    }
    connection.commit();
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    connection.rollback();
  }
 finally {
    if (resultSet != null) {
      resultSet.close();
    }
    if (statement != null) {
      statement.close();
    }
    if (preparedStatement != null) {
      preparedStatement.close();
    }
    if (connection != null) {
      connection.close();
    }
  }
  log.info("String_Node_Str");
}

Fixed version (ground truth):
protected void updateAPIManagerDatabase(String sqlScriptPath) throws SQLException {
  log.info("String_Node_Str");
  Connection connection=null;
  PreparedStatement preparedStatement=null;
  Statement statement=null;
  ResultSet resultSet=null;
  try {
    connection=APIMgtDBUtil.getConnection();
    connection.setAutoCommit(false);
    String dbType=MigrationDBCreator.getDatabaseType(connection);
    if (Constants.DB_TYPE_MYSQL.equals(dbType)) {
      statement=connection.createStatement();
      resultSet=statement.executeQuery(GET_MYSQL_SESSION_MODE);
      if (resultSet.next()) {
        String mode=resultSet.getString("String_Node_Str");
        log.info("String_Node_Str" + mode);
        if (mode.contains(NO_ZERO_DATE_MODE)) {
          File timeStampFixScript=new File(sqlScriptPath + dbType + "String_Node_Str");
          if (timeStampFixScript.exists()) {
            log.info(NO_ZERO_DATE_MODE + "String_Node_Str");
            InputStream is=new FileInputStream(timeStampFixScript);
            List<String> sqlStatements=readSQLStatements(is,dbType);
            for (            String sqlStatement : sqlStatements) {
              preparedStatement=connection.prepareStatement(sqlStatement);
              preparedStatement.execute();
              connection.commit();
            }
          }
        }
      }
    }
    InputStream is=new FileInputStream(sqlScriptPath + dbType + "String_Node_Str");
    List<String> sqlStatements=readSQLStatements(is,dbType);
    for (    String sqlStatement : sqlStatements) {
      log.debug("String_Node_Str" + sqlStatement);
      if (Constants.DB_TYPE_ORACLE.equals(dbType)) {
        statement=connection.createStatement();
        statement.executeUpdate(sqlStatement);
      }
 else {
        preparedStatement=connection.prepareStatement(sqlStatement);
        preparedStatement.execute();
      }
    }
    connection.commit();
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    connection.rollback();
  }
 finally {
    if (resultSet != null) {
      resultSet.close();
    }
    if (statement != null) {
      statement.close();
    }
    if (preparedStatement != null) {
      preparedStatement.close();
    }
    if (connection != null) {
      connection.close();
    }
  }
  log.info("String_Node_Str");
}