Skip to content

Commit 06e6548

Browse files
committed
Ick. Need to still update results and count if no result for first statement
1 parent 436600a commit 06e6548

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -487,19 +487,24 @@ public IRubyObject execute(final ThreadContext context, final IRubyObject sql) {
487487
while (hasResultSet || updateCount != -1) {
488488
if (hasResultSet) {
489489
ResultSet resultSet = statement.getResultSet();
490-
491-
// Check to see if there is another result set
492-
hasResultSet = statement.getMoreResults();
493-
// No next result so process what we have and return
494-
if (!hasResultSet) {
495-
// For SELECT queries, return propr Result object
496-
IRubyObject result = mapQueryResult(context, connection, resultSet);
490+
try {
491+
// Check to see if there is another result set
492+
hasResultSet = statement.getMoreResults();
493+
updateCount = statement.getUpdateCount();
494+
495+
// No next result so process what we have and return
496+
if (!hasResultSet && updateCount == -1) {
497+
// For SELECT queries, return propr Result object
498+
IRubyObject result = mapQueryResult(context, connection, resultSet);
499+
return result;
500+
}
501+
} finally {
497502
resultSet.close();
498-
return result;
499503
}
504+
} else {
505+
hasResultSet = statement.getMoreResults();
506+
updateCount = statement.getUpdateCount();
500507
}
501-
502-
updateCount = statement.getUpdateCount();
503508
}
504509

505510
return newEmptyResult(context);

0 commit comments

Comments
 (0)