public boolean next()

in elastic-db-tools/src/main/java/com/microsoft/azure/elasticdb/query/multishard/MultiShardResultSet.java [70:109]


    public boolean next() throws SQLException {
        if (currentIndex > results.size()) {
            return false;
        }
        if (currentResultSet == null) {
            // This is the first time next is called.
            do {
                // Populate currentResultSet.
                currentResultSet = results.get(currentIndex);
                // Increment currentIndex.
                currentIndex++;
                // Do this until you get a result set which isn't null.
            }
            while (currentIndex < results.size() && currentResultSet.getResultSet() == null);

            // If we don't have result sets throw MultiShardResultSetClosedException exception
            if (currentResultSet.getResultSet() == null) {
                throw new MultiShardResultSetClosedException("Statement did not return ResultSet");
            }

            return currentResultSet.getResultSet().next();
        }
        else {
            ResultSet currentSet = currentResultSet.getResultSet();
            if (currentSet.next()) {
                return true;
            }
            while (currentIndex < results.size()) {
                currentResultSet = results.get(currentIndex);
                currentIndex++;
                if (currentResultSet.getResultSet() != null && currentResultSet.getResultSet().next()) {
                    return true;
                }
            }
        }
        // Increment current index to handle further calls
        currentIndex++;
        // We have reached the end of the result.
        return false;
    }