Use
while (selectResult.hasNext())
instead?
On Mon, Feb 3, 2020 at 5:25 PM Steve Vestal
<[email protected]> wrote:
>
> A beginner's question. I would like to iterate over all the solutions
> from a select query. If I execute
>
> QueryExecution qexec =
> QueryExecutionFactory.create(mySelectQuery, myModel);
> ResultSet selectResult = qexec.execSelect();
> String results = ResultSetFormatter.asText(selectResult);
> System.err.println(results);
>
> I get a printout that shows several rows of solutions. If I execute
>
> QueryExecution qexec =
> QueryExecutionFactory.create(mySelectQuery, myModel);
> ResultSet selectResult = qexec.execSelect();
> int rowCnt = 0;
> if (selectResult.hasNext()) {
> rowCnt = rowCnt + 1;
> QuerySolution selectRow = selectResult.next();
> }
> System.err.println("Found " + rowCnt + " solutions.");
>
> it tells me it found 1 solution. How do I iterate over the individual
> rows shown in the asText print?
>