简体   繁体   中英

Exception while executing a query

I am trying to query the Dbpedia datasets via their remote sparql endpoints. So far I have managed to connect to the end points and execute normal queries. But when I execute the following query I get some results and then an exception that I have no clue of. Could someone please help. The query and the exception is as follows.

SELECT DISTINCT ?p ?o WHERE 
{ ?p ?x <http://dbpedia.org/resource/Nepal>.
  ?p <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o. }

and the exception is as follows

16:51:30 WARN  XMLInputStAX$ResultSetStAX :: StAX error: XMLStreamException: Unexpected EOF; was expecting a close tag for element <result>
 at [row,col {unknown-source}]: [2068,3]
com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <result>
 at [row,col {unknown-source}]: [2068,3]
        at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:686)
        at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2730)
        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1019)
        at com.hp.hpl.jena.sparql.resultset.XMLInputStAX$ResultSetStAX.getOneSolution(XMLInputStAX.java:410)
        at com.hp.hpl.jena.sparql.resultset.XMLInputStAX$ResultSetStAX.hasNext(XMLInputStAX.java:217)
        at sat.Algorithm.incomingLink(Algorithm.java:128)
        at sat.Main.main(Main.java:20)
2 [main] WARN com.hp.hpl.jena.sparql.resultset.XMLInputStAX$ResultSetStAX  - StAX error: XMLStreamException: Unexpected EOF; was expecting a close tag for element <result>
 at [row,col {unknown-source}]: [2068,3]..........

Has this got to do with the amount of results being too large and Jena not being able to handle it?? Personally am not sure because the number of results that get displayed successfully seems to be different at every execution. So could someone please help.

Try using projections such as LIMIT and OFFSET to control the size of the resultset. DPBEDIA by default limits to 10,000 although depending on the amount of memory allocated to the JVM, this shouldn't be an issue. I take it use are using the Jena ARQ API'S and using the sparqlService method. Something like this:

QueryExecution qe = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", "SELECT DISTINCT ?p ?o WHERE { ?p ?x <http://dbpedia.org/resource/Nepal>. ?p <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o. }");
ResultSet queryResults = qe.execSelect(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM