JdbcStatement.getMoreResults(int flag) behaves differently from the parameter-less JdbcStatement.getMoreResults() even when they both close the resultSet and return false.
the behavior of JdbcStatement.getMoreResults(int flag) is causing a major problem with the Railo application server (as documented at
https://issues.jboss.org/browse/RAILO-1638) and makes H2 impossible unusable in Railo.
since both methods always return false, perhaps a good solution would be to call the parameter-less method from within the parameterized version when the flag is set to Close? i.e.
/**
* Move to the next result set.
* This method always returns false.
*
* @param current Statement.CLOSE_CURRENT_RESULT,
* Statement.KEEP_CURRENT_RESULT,
* or Statement.CLOSE_ALL_RESULTS
* @return false
*/
public boolean getMoreResults(int current) throws SQLException {
try {
debugCodeCall("getMoreResults", current);
switch (current) {
case Statement.CLOSE_CURRENT_RESULT:
case Statement.CLOSE_ALL_RESULTS:
// if (resultSet != null) {
// resultSet.close();
// }
getMoreResults();
break;
case Statement.KEEP_CURRENT_RESULT:
// nothing to do
break;
default:
throw DbException.getInvalidValueException("current", current);
}
return false;
} catch (Exception e) {
throw logAndConvert(e);
}
}
//-------- code below shows current code --------//
/**
* Moves to the next result set - however there is always only one result
* set. This call also closes the current result set (if there is one).
* Returns true if there is a next result set (that means - it always
* returns false).
*
* @return false
* @throws SQLException if this object is closed.
*/
public boolean getMoreResults() throws SQLException {
try {
debugCodeCall("getMoreResults");
checkClosed();
closeOldResultSet();
return false;
} catch (Exception e) {
throw logAndConvert(e);
}
}
/**
* Move to the next result set.
* This method always returns false.
*
* @param current Statement.CLOSE_CURRENT_RESULT,
* Statement.KEEP_CURRENT_RESULT,
* or Statement.CLOSE_ALL_RESULTS
* @return false
*/
public boolean getMoreResults(int current) throws SQLException {
try {
debugCodeCall("getMoreResults", current);
switch (current) {
case Statement.CLOSE_CURRENT_RESULT:
case Statement.CLOSE_ALL_RESULTS:
if (resultSet != null) {
resultSet.close();
}
break;
case Statement.KEEP_CURRENT_RESULT:
// nothing to do
break;
default:
throw DbException.getInvalidValueException("current", current);
}
return false;
} catch (Exception e) {
throw logAndConvert(e);
}
}