I tried to help you on StackOverflow, but no response from your side and
you posted something that can't compile in Java.
Moreover, and that's a really sad point, you posted a different query
there, without the Mathscore triple patterns...
Off-topic: It would be good if you close the question there if you found
the solution, that's one of the expected behaviors on a platform like
StackOverflow.
More comments, your query asks for the top English score - your message
tells the user that it's the top Physics score...
And the exception is quite obvious, you called next() twice on a
resultset which might only return one student with the highest score.
> Hello, this is the query. How can we add high score of another subject like
> Mathsscore, I simply add Mathscore after Englishscore, but not working
>
> "SELECT * +
>
> " WHERE {" + " {"+ "select (max(?score) as ?highScore)"
> + " { ?student dd:Englishscore ?score" + " ?student2 dd:Mathsscore
> ?score2"
> " }" +
> " } " +
> "?student dd:Englishscore ?highScore" + " ?student2
> dd:Mathsscore ?score2"
>
>
> "}";
>
> On Thu, Jan 26, 2017 at 6:13 PM, javed khan <[email protected]> wrote:
>
>> I am sorry Rob, I have posted this issue on Stack overflow yesterday, and
>> I thought I have posted the details here.
>> Sorry and the problem is solved as I used QuerySolution in while loop.
>>
>> Thank you
>>
>> On Thu, Jan 26, 2017 at 5:12 PM, Rob Vesse <[email protected]> wrote:
>>
>>> Once again you have failed to provide a minimal complete example. This
>>> means the minimal code needed to reproduce the problem and any extra
>>> resources needed e.g. your data. Complete means that your code should be
>>> able to be copied and pasted and run.
>>>
>>> http://stackoverflow.com/help/mcve
>>>
>>> Note you haven’t actually told us what the problem is i.e. What is the
>>> specific error message you got. It gets an exception is not a problem
>>> statement!
>>>
>>> We have been telling you this for weeks, if you are not actually going
>>> to make an effort then people are going to stop trying to help you
>>>
>>> Rob
>>>
>>> On 26/01/2017 13:06, "javed khan" <[email protected]> wrote:
>>>
>>> *The following query works * :
>>>
>>> "SELECT ?student ?highScore " +
>>>
>>> " WHERE {" + " {"+ "select (max(?score) as
>>> ?highScore)"
>>> + " { ?student dd:Englishscore ?score" +
>>> " }" +
>>> " } " +
>>> "?student dd:Englishscore ?highScore" +
>>>
>>>
>>> "}";
>>>
>>> Query query2 = QueryFactory.create(queryString2);
>>> QueryExecution qexec = QueryExecutionFactory.create(query2, model2) ;
>>> ResultSet results2 = qexec.execSelect() ;
>>>
>>> Literal r= results2.next().get("highScore").asLiteral();
>>> String ss= r.getLexicalForm();
>>> JOptionPane.showMessageDialog(null,"High score of Physics is"+s +
>>> "by
>>> Student");
>>>
>>> This query now works but when I include also the student name, it
>>> gives me
>>> exception again.
>>>
>>> * Resource r2= results2.next().get("student").asResource();*
>>> * String s=r2.toString();*
>>>
>>>
>>>
>>>
>>>
>>>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center