*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();*