Program: 166453
Project: 166453
Buggy source:
/** 
 * The main loop for the Jisql program. This method handles the input from either a command line or from a file. Output is handled through the Formatter.
 * @throws SQLException if an exception occurs.
 */
public void doIsql() throws SQLException {
  BufferedReader reader=null;
  Statement statement=null;
  ResultSet resultSet=null;
  ResultSetMetaData resultSetMetaData=null;
  StringBuffer query=null;
  if (inputFileName != null) {
    try {
      reader=new BufferedReader(new FileReader(inputFileName));
    }
 catch (    FileNotFoundException fnfe) {
      System.err.println("String_Node_Str" + inputFileName + "String_Node_Str");
      fnfe.printStackTrace(System.err);
      return;
    }
  }
 else {
    reader=new BufferedReader(new InputStreamReader(System.in));
  }
  if (printDebug)   printAllExceptions(connection.getWarnings());
  statement=connection.createStatement();
  connection.clearWarnings();
  String trimmedLine=null;
  try {
    while (true) {
      int linecount=1;
      query=new StringBuffer();
      try {
        if ((inputFileName == null) && (inputQuery == null))         System.out.print("String_Node_Str");
        while (true) {
          if ((inputFileName == null) && (inputQuery == null)) {
            System.out.print(linecount++ + "String_Node_Str");
            System.out.flush();
          }
          String line=null;
          if (inputQuery == null)           line=reader.readLine();
 else           line=inputQuery.toString();
          if (line == null || line.equalsIgnoreCase("String_Node_Str") || line.equalsIgnoreCase("String_Node_Str")) {
            if ((inputFileName != null) && (inputQuery != null)) {
              break;
            }
 else {
              return;
            }
          }
          if (line.equals("String_Node_Str")) {
            query=new StringBuffer();
            break;
          }
          trimmedLine=line.trim();
          if (trimmedLine.startsWith("String_Node_Str") || trimmedLine.length() < 1) {
            continue;
          }
          if (connectString.toLowerCase().startsWith("String_Node_Str") && inputFileName != null) {
            if (trimmedLine.startsWith("String_Node_Str") || trimmedLine.length() < 2) {
              commandTerminator="String_Node_Str";
              continue;
            }
          }
          if (line.trim().equalsIgnoreCase(commandTerminator) || line.trim().endsWith(commandTerminator)) {
            if (line.trim().endsWith(commandTerminator)) {
              line=line.substring(0,line.length() - commandTerminator.length());
              query.append("String_Node_Str");
              query.append(line);
            }
            break;
          }
          query.append("String_Node_Str");
          query.append(line);
        }
        if (query.toString().length() == 0)         continue;
        if (printDebug)         System.out.println("String_Node_Str" + query.toString());
        boolean moreResults=statement.execute(query.toString());
        int rowsAffected=0;
        do {
          if (printDebug)           printAllExceptions(statement.getWarnings());
          statement.clearWarnings();
          if (moreResults) {
            resultSet=statement.getResultSet();
            if (printDebug)             printAllExceptions(resultSet.getWarnings());
            resultSet.clearWarnings();
            resultSetMetaData=resultSet.getMetaData();
            formatter.formatHeader(System.out,resultSetMetaData);
            formatter.formatData(System.out,resultSet,resultSetMetaData);
            formatter.formatFooter(System.out,resultSetMetaData);
            int rowsSelected=statement.getUpdateCount();
            if (rowsSelected >= 0 && printDebug) {
              System.out.println(rowsSelected + "String_Node_Str");
            }
          }
 else {
            rowsAffected=statement.getUpdateCount();
            if (printDebug)             printAllExceptions(statement.getWarnings());
            statement.clearWarnings();
            if (rowsAffected >= 0 && printDebug) {
              System.out.println(rowsAffected + "String_Node_Str");
            }
          }
          try {
            moreResults=statement.getMoreResults();
          }
 catch (          NullPointerException npe) {
            moreResults=false;
          }
        }
 while (moreResults || rowsAffected != -1);
      }
 catch (      SQLException sqle) {
        printAllExceptions(sqle);
        statement.cancel();
        statement.clearWarnings();
      }
catch (      Exception e) {
        e.printStackTrace(System.err);
      }
      if (inputQuery != null)       return;
    }
  }
  finally {
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      IOException ioe) {
      }
    }
    if (statement != null) {
      try {
        if (!statement.isClosed()) {
          statement.close();
        }
      }
 catch (      SQLException sqle) {
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * The main loop for the Jisql program. This method handles the input from either a command line or from a file. Output is handled through the Formatter.
 * @throws SQLException if an exception occurs.
 */
public void doIsql() throws SQLException {
  BufferedReader reader=null;
  Statement statement=null;
  ResultSet resultSet=null;
  ResultSetMetaData resultSetMetaData=null;
  StringBuffer query=null;
  if (inputFileName != null) {
    try {
      reader=new BufferedReader(new FileReader(inputFileName));
    }
 catch (    FileNotFoundException fnfe) {
      System.err.println("String_Node_Str" + inputFileName + "String_Node_Str");
      fnfe.printStackTrace(System.err);
      return;
    }
  }
 else {
    reader=new BufferedReader(new InputStreamReader(System.in));
  }
  if (printDebug)   printAllExceptions(connection.getWarnings());
  statement=connection.createStatement();
  connection.clearWarnings();
  String trimmedLine=null;
  try {
    while (true) {
      int linecount=1;
      query=new StringBuffer();
      try {
        if ((inputFileName == null) && (inputQuery == null))         System.out.print("String_Node_Str");
        while (true) {
          if ((inputFileName == null) && (inputQuery == null)) {
            System.out.print(linecount++ + "String_Node_Str");
            System.out.flush();
          }
          String line=null;
          if (inputQuery == null)           line=reader.readLine();
 else           line=inputQuery.toString();
          if (line == null || line.equalsIgnoreCase("String_Node_Str") || line.equalsIgnoreCase("String_Node_Str")) {
            if ((inputFileName != null) && (inputQuery != null)) {
              break;
            }
 else {
              return;
            }
          }
          if (line.equals("String_Node_Str")) {
            query=new StringBuffer();
            break;
          }
          trimmedLine=line.trim();
          if (trimmedLine.startsWith("String_Node_Str") || trimmedLine.length() < 1) {
            continue;
          }
          if (connectString.toLowerCase().startsWith("String_Node_Str") && inputFileName != null) {
            if (trimmedLine.startsWith("String_Node_Str") || trimmedLine.length() < 2) {
              commandTerminator="String_Node_Str";
              continue;
            }
          }
          if (line.trim().equalsIgnoreCase(commandTerminator) || line.trim().endsWith(commandTerminator)) {
            if (line.trim().endsWith(commandTerminator)) {
              line=line.substring(0,line.length() - commandTerminator.length());
              query.append("String_Node_Str");
              query.append(line);
            }
            break;
          }
          query.append("String_Node_Str");
          query.append(line);
        }
        if (query.toString().length() == 0)         continue;
        if (printDebug)         System.out.println("String_Node_Str" + query.toString());
        boolean moreResults=statement.execute(query.toString());
        int rowsAffected=0;
        do {
          if (printDebug)           printAllExceptions(statement.getWarnings());
          statement.clearWarnings();
          if (moreResults) {
            resultSet=statement.getResultSet();
            if (printDebug)             printAllExceptions(resultSet.getWarnings());
            resultSet.clearWarnings();
            resultSetMetaData=resultSet.getMetaData();
            formatter.formatHeader(System.out,resultSetMetaData);
            formatter.formatData(System.out,resultSet,resultSetMetaData);
            formatter.formatFooter(System.out,resultSetMetaData);
            int rowsSelected=statement.getUpdateCount();
            if (rowsSelected >= 0 && printDebug) {
              System.out.println(rowsSelected + "String_Node_Str");
            }
          }
 else {
            rowsAffected=statement.getUpdateCount();
            if (printDebug)             printAllExceptions(statement.getWarnings());
            statement.clearWarnings();
            if (rowsAffected >= 0 && printDebug) {
              System.out.println(rowsAffected + "String_Node_Str");
            }
          }
          try {
            moreResults=statement.getMoreResults();
          }
 catch (          NullPointerException npe) {
            moreResults=false;
          }
        }
 while (moreResults || rowsAffected != -1);
      }
 catch (      SQLException sqle) {
        printAllExceptions(sqle);
        statement.cancel();
        statement.clearWarnings();
      }
catch (      Exception e) {
        e.printStackTrace(System.err);
      }
      if (inputQuery != null)       return;
    }
  }
  finally {
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      IOException ioe) {
      }
    }
    if (statement != null) {
      try {
        statement.close();
      }
 catch (      SQLException sqle) {
      }
    }
  }
}