From 36a013c4a6f00202ef47e7f9da6c1c92007c89fe Mon Sep 17 00:00:00 2001 From: Eric Draken Date: Sun, 19 Jan 2020 22:12:05 -0800 Subject: [PATCH] Spring Boot sometimes returns a RecordSet that starts from the first entry, not "before" the first entry. This fix takes into account this already-advanced RecordSet. --- src/net/efabrika/util/DBTablePrinter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/net/efabrika/util/DBTablePrinter.java b/src/net/efabrika/util/DBTablePrinter.java index b2204f7..0761be4 100644 --- a/src/net/efabrika/util/DBTablePrinter.java +++ b/src/net/efabrika/util/DBTablePrinter.java @@ -461,7 +461,12 @@ public static void printResultSet(ResultSet rs, int maxStringColWidth) { // Go through each row, get values of each column and adjust // column widths. int rowCount = 0; - while (rs.next()) { + if ( ! rs.isAfterLast() ) // No rows are printed if the RS advanced too far already + { + if ( rs.isBeforeFirst() ) // Ensure starting from the first record + { + rs.next(); + } // NOTE: columnIndex for rs.getXXX methods STARTS AT 1 NOT 0 for (int i = 0; i < columnCount; i++) { @@ -508,7 +513,7 @@ public static void printResultSet(ResultSet rs, int maxStringColWidth) { } // END of for loop columnCount rowCount++; - } // END of while (rs.next) + } while ( rs.next() ); /* At this point we have gone through meta data, get the