Uploaded image for project: 'Commons CSV'
  1. Commons CSV
  2. CSV-138

CSVPrinter.printRecords(ResultSet) skips first row with SQLServer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 1.0
    • None
    • Printer
    • None

    Description

      WIth SQLServer's 2012 jdbc driver 4.0, when I call CSVPrinter#printRecords with a java.sql.ResultSet, the first row is not printed. It appears that the line

      final int columnCount = resultSet.getMetaData().getColumnCount();
      

      positions the cursor on the first row and then when

       while (resultSet.next()) { ...
      

      is called, the 2nd row onwards is what is getting outputted.

      As a workaround, I used :

      final int columnCount = rs.getMetaData().getColumnCount();
      do {
          for (int i = 1; i <= columnCount; i++) {
              csvPrinter.print(rs.getString(i));
          }
          csvPrinter.println();
      } while (rs.next());
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            alankstewart Alan Stewart
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: