简体   繁体   English

执行查询时出现异常

[英]Exception while executing a query

I am trying to query the Dbpedia datasets via their remote sparql endpoints.我正在尝试通过其远程 sparql 端点查询 Dbpedia 数据集。 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??这是否与结果量太大而 Jena 无法处理有关? 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.尝试使用 LIMIT 和 OFFSET 等投影来控制结果集的大小。 DPBEDIA by default limits to 10,000 although depending on the amount of memory allocated to the JVM, this shouldn't be an issue. DPBEDIA 默认限制为 10,000,但取决于分配给 JVM 的 memory 的数量,这应该不是问题。 I take it use are using the Jena ARQ API'S and using the sparqlService method.我认为它使用的是 Jena ARQ API'S 和 sparqlService 方法。 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(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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