Requirements of getMoreResults()/getMoreResults(int)
Mark Rotteveel
mark at lawinegevaar.nl
Sun Nov 22 10:26:24 UTC 2015
I just ran into a question on stackoverflow,
http://stackoverflow.com/q/33853354/466862 about the requirements for
getMoreResults() vs getMoreResults(int).
The description of getMoreResults() says:
"and implicitly closes any current ResultSet object(s) obtained with the
method getResultSet."
As it uses **any** and object**(s)**, this sounds to me like its
behavior should be the equivalent of
getMoreResults(Statement.CLOSE_ALL_RESULTS), however getMoreResults(int)
says:
"SQLFeatureNotSupportedException - if
DatabaseMetaData.supportsMultipleOpenResults returns false and either
Statement.KEEP_CURRENT_RESULT or Statement.CLOSE_ALL_RESULTS are
supplied as the argument."
This was added in JDBC 4, JDBC 3 had no such requirement.
So, what is the required behavior for getMoreResults()? Is it always
getMoreResults(Statement.CLOSE_CURRENT_RESULT), or is it
getMoreResults(Statement.CLOSE_CURRENT_RESULT) in a driver that does not
support multiple results, and
getMoreResults(Statement.CLOSE_ALL_RESULTS) in a driver that does
support multiple open results?
If the second, then I think for a driver that does not support multiple
open results this distinction is unnecessary, because then closing the
current result is the same as closing all results (as there is only one
open result); and then the requirement to throw
SQLFeatureNotSupportedException for Statement.CLOSE_ALL_RESULTS is also
unnecessary.
On a related note, the DatabaseMetData.supportsMultipleOpenResults says:
"Retrieves whether it is possible to have multiple ResultSet objects
returned from a CallableStatement object simultaneously."
I think CallableStatement should be changed to Statement as you can call
stored procedures (or other statements) that have multiple results also
with Statement or PreparedStatement.
Mark Rotteveel
--
Mark Rotteveel
More information about the jdbc-spec-discuss
mailing list