@@ -247,34 +247,49 @@ public <E> Cursor<E> handleCursorResultSets(Statement stmt) throws SQLException
247
247
}
248
248
249
249
private ResultSetWrapper getFirstResultSet (Statement stmt ) throws SQLException {
250
- ResultSet rs = stmt .getResultSet ();
251
- while (rs == null ) {
252
- // move forward to get the first resultset in case the driver
253
- // doesn't return the resultset as the first result (HSQLDB)
254
- if (stmt .getMoreResults ()) {
255
- rs = stmt .getResultSet ();
256
- } else if (stmt .getUpdateCount () == -1 ) {
257
- // no more results. Must be no resultset
258
- break ;
250
+ ResultSet rs = null ;
251
+ SQLException e1 = null ;
252
+
253
+ try {
254
+ rs = stmt .getResultSet ();
255
+ } catch (SQLException e ) {
256
+ // Oracle throws ORA-17283 for implicit cursor
257
+ e1 = e ;
258
+ }
259
+
260
+ try {
261
+ while (rs == null ) {
262
+ // move forward to get the first resultset in case the driver
263
+ // doesn't return the resultset as the first result (HSQLDB)
264
+ if (stmt .getMoreResults ()) {
265
+ rs = stmt .getResultSet ();
266
+ } else if (stmt .getUpdateCount () == -1 ) {
267
+ // no more results. Must be no resultset
268
+ break ;
269
+ }
259
270
}
271
+ } catch (SQLException e ) {
272
+ throw e1 != null ? e1 : e ;
260
273
}
274
+
261
275
return rs != null ? new ResultSetWrapper (rs , configuration ) : null ;
262
276
}
263
277
264
278
private ResultSetWrapper getNextResultSet (Statement stmt ) {
265
279
// Making this method tolerant of bad JDBC drivers
266
280
try {
267
- if (stmt .getConnection ().getMetaData ().supportsMultipleResultSets ()) {
268
- // Crazy Standard JDBC way of determining if there are more results
269
- // DO NOT try to 'improve' the condition even if IDE tells you to!
270
- // It's important that getUpdateCount() is called here.
271
- if (!(!stmt .getMoreResults () && stmt .getUpdateCount () == -1 )) {
272
- ResultSet rs = stmt .getResultSet ();
273
- if (rs == null ) {
274
- return getNextResultSet (stmt );
275
- } else {
276
- return new ResultSetWrapper (rs , configuration );
277
- }
281
+ // We stopped checking DatabaseMetaData#supportsMultipleResultSets()
282
+ // because Oracle driver (incorrectly) returns false
283
+
284
+ // Crazy Standard JDBC way of determining if there are more results
285
+ // DO NOT try to 'improve' the condition even if IDE tells you to!
286
+ // It's important that getUpdateCount() is called here.
287
+ if (!(!stmt .getMoreResults () && stmt .getUpdateCount () == -1 )) {
288
+ ResultSet rs = stmt .getResultSet ();
289
+ if (rs == null ) {
290
+ return getNextResultSet (stmt );
291
+ } else {
292
+ return new ResultSetWrapper (rs , configuration );
278
293
}
279
294
}
280
295
} catch (Exception e ) {
0 commit comments