Skip to content

jdbc: Support Statement.getMoreResults  #182

Closed

Description

@nicktorwald

If there are multiple results or if the type or number of results returned by a Statement object are not known until run time, the Statement object should be executed with the method execute. The methods getMoreResults, getUpdateCount, and getResultSet can be used to retrieve all the results.

By default, each call to the method getMoreResults closes any previous ResultSet object returned by the method getResultSet. However, the method getMoreResults may take a parameter that specifies whether a ResultSet object returned by getResultSet should be closed. The Statement interface defines three constants that can be supplied to the method getMoreResults:

  • CLOSE_CURRENT_RESULT — indicates that the current ResultSet object should be closed when the next ResultSet object is returned
  • KEEP_CURRENT_RESULT — indicates that the current ResultSet object should not be closed when the next ResultSet object is returned
  • CLOSE_ALL_RESULTS — indicates that any ResultSet objects that have been kept open should be closed when the next result is returned

If the current result is an update count and not a ResultSet object, any parameter passed to getMoreResults is ignored.

To determine whether a driver implements this feature, an application can call the
DatabaseMetaData method supportsMultipleOpenResults.

An example:

Statement stmt = conn.createStatement();
boolean retval = cstmt.execute(sql_queries);
ResultSet rs;
int count;
do {
    if (retval == false) {
        count = stmt.getUpdateCount();
        if (count == -1) {
            // no more results
           break;
        } else {
           // process update count
        }
    } else {
        rs = stmt.getResultSet();
        // process ResultSet
    }
    retval = stmt.getMoreResults();
while (true);

Activity

  1. added this to the JDBC MVP milestone on May 7, 2019
  2. Totktonada commented on May 12, 2019

    @Totktonada

    AFAIK, we cannot receive multiple result sets from tarantool sql now. Are we must support it according to JDBC?

  3. changed the title [-]jdbc: Support Statement multi results[/-] [+]jdbc: Support ResultSet.getMoreResults [/+] on May 13, 2019
  4. nicktorwald commented on May 13, 2019

    @nicktorwald
    Author

    Yeah, we need to support getMoreResults() and getMoreResults(ResultSet.CLOSE_CURRENT_RESULT) even though a single result set. Both cases do the same.
    Right now, we can just return false and close the current result set to follow the spec. We even can support KEEP_CURRENT_RESULT and CLOSE_ALL_RESULTS for the single result set.

    I renamed the issue to be more precise.

  5. Totktonada commented on May 20, 2019

    @Totktonada

    Okay. Let's consider this issue as the task to appropriate support the API.

  6. added a commit that references this issue on May 29, 2019
    d16757b
  7. changed the title [-]jdbc: Support ResultSet.getMoreResults [/-] [+]jdbc: Support Statement.getMoreResults [/+] on May 29, 2019
  8. added a commit that references this issue on May 29, 2019
    7effea6
  9. added a commit that references this issue on Jun 12, 2019
    ea52075
  10. added a commit that references this issue on Jun 12, 2019
    2473ffa
  11. added a commit that references this issue on Jul 1, 2019
    d40ba87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions