Hello. 
Unless you have a dynamically created string your use of " " and + to break up 
strings isn't helping readability.
Perhaps you could format the query as one string as part of the complete 
minimum example that would allow people to help you?
Following a few simple mailing list guides and some basic chosen programming 
language best practices will make your life a lot easier!
That said I suspect the asLiteral() statements would be a good starting 
point... I also suggest understanding which part of a triple can be a literal.
Dick Murray


-------- Original message --------From: javed khan <[email protected]> 
Date: 08/01/2017  18:32  (GMT+00:00) To: [email protected] Subject: Literal 
Required Exception in SPARQL 
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"   +

          "}";


             Query query2 = QueryFactory.create(queryString2);
QueryExecution qexec = QueryExecutionFactory.create(query2, model) ;
ResultSet results2 = qexec.execSelect() ;

       Literal l2=results2.next().get("student").asLiteral();
        Literal l3=results2.next().get("highScore").asLiteral();
String s=l3.toString();
        JOptionPane.showMessageDialog(null,"high score is" + s );

Reply via email to