Skip to content

Commit 8d46d26

Browse files
committed
Not every JDBC driver returns a resultset as the first result of a stored procedure call (I'm looking at you HSQLDB 2.1.0)
1 parent b6a503d commit 8d46d26

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/org/apache/ibatis/executor/resultset/FastResultSetHandler.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ public List handleResultSets(Statement stmt) throws SQLException {
9292
int resultMapCount = resultMaps.size();
9393
int resultSetCount = 0;
9494
ResultSet rs = stmt.getResultSet();
95+
96+
while (rs == null) {
97+
// move forward to get the first resultset in case the driver
98+
// doesn't return the resultset as the first result (HSQLDB 2.1)
99+
if (stmt.getMoreResults()) {
100+
rs = stmt.getResultSet();
101+
} else {
102+
if (stmt.getUpdateCount() == -1) {
103+
// no more results. Must be no resultset
104+
break;
105+
}
106+
}
107+
}
108+
95109
validateResultMapsCount(rs, resultMapCount);
96110
while (rs != null && resultMapCount > resultSetCount) {
97111
final ResultMap resultMap = resultMaps.get(resultSetCount);

0 commit comments

Comments
 (0)