Hello Lorenz, yes I need student and highscore.
I just tried this , no exception but it does not display the message in
JOptionPane.showMessageDialog()
Query query2 = QueryFactory.create(queryString2);
QueryExecution qexec = QueryExecutionFactory.create(query2, model) ;
ResultSet results2 = qexec.execSelect() ;
RDFNode r;
while(results2.hasNext()){
QuerySolution sol= results2.nextSolution();
r=sol.get("student");
JOptionPane.showMessageDialog(null,"high score is" + r );
}
On Mon, Jan 9, 2017 at 1:42 PM, Lorenz Buehmann <
[email protected]> wrote:
> @ As per the previous discussion, I guess he also wants to have the
> student - and of course the highest score,
>
> As Chris said, you have to distinguish between literals and URIs/blank
> nodes.
>
> Which finally leads me to the suggestion to read an RDF tutorial +
> SPARQL tutorial first. Most questions are really basic.
>
>
> On 09.01.2017 09:38, Chris Dollin wrote:
> >
> >
> > On 08/01/17 18:32, javed khan wrote:
> >> This query gives me exception:
> >>
> >> Exception in thread "AWT-EventQueue-0"
> >> com.hp.hpl.jena.rdf.model.LiteralRequiredException:
> >> http://www.semanticweb.org/t/ontologies#Smith
> >>
> >> "SELECT * " +
> >>
> >> " WHERE {" + " {"+ "select (max(?score) as
> >> ?highScore)"
> >> + " { ?student std:Englishscore ?score" +
> >> " }" +
> >> " } " +
> >> "?student std:Englishscore ?highScore" +
> >>
> >> "}";
> >
> > The variable ?subject will be the subject of a triple.
> > Subjects may be blank nodes or resources with URIs.
> >
> >> Query query2 = QueryFactory.create(queryString2);
> >> QueryExecution qexec = QueryExecutionFactory.create(query2, model) ;
> >> ResultSet results2 = qexec.execSelect() ;
> >>
> >> Literal l2=results2.next().get("student").asLiteral();
> >
> > get("student") will return the value of "student", which will
> > be a resource or blank node, but NOT a literal. asLiteral
> > expects a Literal.
> >
> > BOOM.
> >
> > My pre-caffeine guess is that you want "highscore" not "student".
> > As others have said, offer complete minimal examples.
> >
> > Chris
> >
>
>