Skip to content

jdbc: Support Statement.getMoreResults #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nicktorwald opened this issue May 6, 2019 · 3 comments · Fixed by #193
Closed

jdbc: Support Statement.getMoreResults #182

nicktorwald opened this issue May 6, 2019 · 3 comments · Fixed by #193
Labels
Milestone

Comments

@nicktorwald
Copy link

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);
@nicktorwald nicktorwald added this to the JDBC MVP milestone May 7, 2019
@Totktonada
Copy link
Member

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

@nicktorwald nicktorwald changed the title jdbc: Support Statement multi results jdbc: Support ResultSet.getMoreResults May 13, 2019
@nicktorwald
Copy link
Author

nicktorwald commented May 13, 2019

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.

@Totktonada
Copy link
Member

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

nicktorwald added a commit that referenced this issue May 29, 2019
Add support for two methods getMoreResults and its synonym
getMoreResults(CLOSE_CURRENT_RESULT). Tarantool does not support
multiple results per one query. It leads both KEEP_CURRENT_RESULT and
CLOSE_ALL_RESULTS modes are not supported by the driver.

Closes: #182
@nicktorwald nicktorwald changed the title jdbc: Support ResultSet.getMoreResults jdbc: Support Statement.getMoreResults May 29, 2019
nicktorwald added a commit that referenced this issue May 29, 2019
Add support for two methods getMoreResults and its synonym
getMoreResults(CLOSE_CURRENT_RESULT). Tarantool does not support
multiple results per one query. It leads both KEEP_CURRENT_RESULT and
CLOSE_ALL_RESULTS modes are not supported by the driver.

Closes: #182
nicktorwald added a commit that referenced this issue Jun 12, 2019
Add support for two methods getMoreResults and its synonym
getMoreResults(CLOSE_CURRENT_RESULT). Tarantool does not support
multiple results per one query. It leads both KEEP_CURRENT_RESULT and
CLOSE_ALL_RESULTS modes are not supported by the driver.

Closes: #182
nicktorwald added a commit that referenced this issue Jun 12, 2019
Add support for two methods getMoreResults and its synonym
getMoreResults(CLOSE_CURRENT_RESULT). Tarantool does not support
multiple results per one query. It leads both KEEP_CURRENT_RESULT and
CLOSE_ALL_RESULTS modes are not supported by the driver.

Closes: #182
nicktorwald added a commit to nicktorwald/tarantool-java that referenced this issue Jul 1, 2019
Add support for two methods getMoreResults and its synonym
getMoreResults(CLOSE_CURRENT_RESULT). Tarantool does not support
multiple results per one query. It leads both KEEP_CURRENT_RESULT and
CLOSE_ALL_RESULTS modes are not supported by the driver.

Closes: tarantool#182
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants