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 <rve...@dotnetrdf.org> 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" <javedbtk...@gmail.com> 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();* > > > > > >