diff options
author | James Moger <james.moger@gitblit.com> | 2015-04-22 17:26:41 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2015-04-22 17:26:41 -0400 |
commit | cf315fa1172cd8ffc11a5a3f3f833303d79db25b (patch) | |
tree | 6b428970c1e060e22c1073193129b0a2ffa72c34 /src/main/java/com/iciql/Db.java | |
parent | 8ac32ab5469d3da41104f91a1c08616a1e1928fb (diff) | |
download | iciql-cf315fa1172cd8ffc11a5a3f3f833303d79db25b.tar.gz iciql-cf315fa1172cd8ffc11a5a3f3f833303d79db25b.zip |
Gracefully handle SQLite's pre-closed ResultSets for queries with 0 returned rows
Diffstat (limited to 'src/main/java/com/iciql/Db.java')
-rw-r--r-- | src/main/java/com/iciql/Db.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/com/iciql/Db.java b/src/main/java/com/iciql/Db.java index 7413c8f..4b55150 100644 --- a/src/main/java/com/iciql/Db.java +++ b/src/main/java/com/iciql/Db.java @@ -414,11 +414,14 @@ public class Db implements AutoCloseable { List<T> result = new ArrayList<T>(); TableDefinition<T> def = (TableDefinition<T>) define(modelClass); try { - int[] columns = def.mapColumns(wildcardSelect, rs); - while (rs.next()) { - T item = Utils.newObject(modelClass); - def.readRow(dialect, item, rs, columns); - result.add(item); + // SQLite returns pre-closed ResultSets for query results with 0 rows + if (!rs.isClosed()) { + int[] columns = def.mapColumns(wildcardSelect, rs); + while (rs.next()) { + T item = Utils.newObject(modelClass); + def.readRow(dialect, item, rs, columns); + result.add(item); + } } } catch (SQLException e) { throw new IciqlException(e); |