Example usage for java.sql CallableStatement getMoreResults

List of usage examples for java.sql CallableStatement getMoreResults

Introduction

In this page you can find the example usage for java.sql CallableStatement getMoreResults.

Prototype

boolean getMoreResults(int current) throws SQLException;

Source Link

Document

Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object.

Usage

From source file:org.wso2.carbon.dataservices.core.description.query.SQLQuery.java

private ResultSet getFirstRSOfStoredProc(CallableStatement stmt) throws SQLException {
    boolean resultAndNoUpdateCount = stmt.execute();
    ResultSet result = null;/*from  w  ww .  j  a v a 2  s .c o m*/
    while (true) {
        if (!resultAndNoUpdateCount) {
            if (stmt.getUpdateCount() == -1) {
                break;
            }
        } else {
            result = stmt.getResultSet();
            break;
        }
        try {
            resultAndNoUpdateCount = stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT);
        } catch (SQLException e) {
            /*
             * for some DBMS, this will throw an unsupported feature
             * exception, even when after a valid result set is retrieved
             * first, so if there's a valid result set existing, we will
             * ignore the eventual unsupported feature exception
             */
            if (result == null) {
                throw e;
            }
            break;
        }
    }
    return result;
}