From e0f9e9a1eb714a05988ae1323ff5e3bd463f64fb Mon Sep 17 00:00:00 2001 From: Matt Innes Date: Mon, 13 May 2019 14:51:22 +0100 Subject: [PATCH] [SQLLINE-379] DB2 JDBC driver throws if SQLLine attempts to call ResultSet.next after last row Based on PR #294 by Matt Innes, with additional code by Julian Hyde. Hoping that it also fixes [SQLLINE-291] sqlite3 java.lang.IllegalStateException: SQLite JDBC: inconsistent internal state --- src/main/java/sqlline/BufferedRows.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/sqlline/BufferedRows.java b/src/main/java/sqlline/BufferedRows.java index 13750156..f85f78fe 100644 --- a/src/main/java/sqlline/BufferedRows.java +++ b/src/main/java/sqlline/BufferedRows.java @@ -102,7 +102,10 @@ private List nextList() throws SQLException { // Add a row of column names as the first row of the first batch. list.add(columnNames); } - if (limit > 0) { + if (rs.isClosed()) { + // Result set is closed. Perhaps the driver closed it automatically + // because we reached the end. Do nothing. + } else if (limit > 0) { // Obey the limit if the limit is non-negative and this is the first // batch. int counter = 0;