Example usage for java.sql Statement KEEP_CURRENT_RESULT

List of usage examples for java.sql Statement KEEP_CURRENT_RESULT

Introduction

In this page you can find the example usage for java.sql Statement KEEP_CURRENT_RESULT.

Prototype

int KEEP_CURRENT_RESULT

To view the source code for java.sql Statement KEEP_CURRENT_RESULT.

Click Source Link

Document

The constant indicating that the current ResultSet object should not be closed when calling getMoreResults.

Usage

From source file:com.alibaba.wasp.jdbc.JdbcStatement.java

/**
 * Move to the next result set. This method always returns false.
 * // www . j a  v  a  2 s .c o m
 * @param current
 *          Statement.CLOSE_CURRENT_RESULT, Statement.KEEP_CURRENT_RESULT, or
 *          Statement.CLOSE_ALL_RESULTS
 * @return false
 */
@Override
public boolean getMoreResults(int current) throws SQLException {
    try {
        switch (current) {
        case Statement.CLOSE_CURRENT_RESULT:
        case Statement.CLOSE_ALL_RESULTS:
            checkClosed();
            closeOldResultSet();
            break;
        case Statement.KEEP_CURRENT_RESULT:
            // nothing to do
            break;
        default:
            throw JdbcException.getInvalidValueException("current", current);
        }
        return false;
    } catch (Exception e) {
        throw Logger.logAndConvert(log, e);
    }
}

From source file:net.starschema.clouddb.jdbc.BQStatementRoot.java

/**
 * <p>//from   www . j  a v  a 2  s  .  c om
 * <h1>Implementation Details:</h1><br>
 * Multiple result sets are not supported currently. we check that the
 * result set is open, the parameter is acceptable, and close our current
 * resultset or throw a FeatureNotSupportedException
 * </p>
 * 
 * @param current
 *            - one of the following Statement constants indicating what
 *            should happen to current ResultSet objects obtained using the
 *            method getResultSet: Statement.CLOSE_CURRENT_RESULT,
 *            Statement.KEEP_CURRENT_RESULT, or Statement.CLOSE_ALL_RESULTS
 * @throws BQSQLException
 */

public boolean getMoreResults(int current) throws SQLException {
    if (this.closed) {
        throw new BQSQLException("Statement is closed.");
    }
    if (current == Statement.CLOSE_CURRENT_RESULT || current == Statement.KEEP_CURRENT_RESULT
            || current == Statement.CLOSE_ALL_RESULTS) {

        if (BQDatabaseMetadata.multipleOpenResultsSupported
                && (current == Statement.KEEP_CURRENT_RESULT || current == Statement.CLOSE_ALL_RESULTS)) {
            throw new BQSQLFeatureNotSupportedException();
        }
        // Statement.CLOSE_CURRENT_RESULT
        this.close();
        return false;
    } else {
        throw new BQSQLException("Wrong parameter.");
    }
}

From source file:org.mule.module.db.internal.result.statement.StatementResultIterator.java

private void moveToNextResult() throws SQLException {
    if (connection.getMetaData().supportsMultipleOpenResults()) {
        statement.getMoreResults(Statement.KEEP_CURRENT_RESULT);
    } else {//from   w w w . j av a  2s .co m
        if (hasProcessedResultSet && resultSetHandler.requiresMultipleOpenedResults()) {
            throw new IllegalStateException(
                    "Database does not supports streaming of resultSets on stored procedures");
        } else {
            statement.getMoreResults();
        }
    }
}

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;//  w  w w . j ava2 s. co  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;
}