线程“main”中的异常com.hp.hpl.jena.query.QueryParseException:第1行第176列的词法错误。遇到:“”(32),之后:“BIND”

时间:2018-03-26 10:36:59

标签: java sparql rdf jena

使用Jena运行以下查询时出现Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Lexical error at line 1, column 176. Encountered: " " (32), after: "BIND"错误,

String queryString = "PREFIX  ns:  <http://example.org/ns#>" + 
                "SELECT  ?title ?price" + 
                "  {" + 
                "    ?x ns:price ?p ." + 
                "    ?x ns:discount ?discount ." + 
                "    ?x <http://purl.org/dc/elements/1.1/title> ?title . " + 
                "    BIND ('12'^^xsd:integer AS ?price)" + 
                "    FILTER( ?price < 20 )" + 
                "  }";

下面是我的堆栈跟踪,

Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Lexical error at line 1, column 176.  Encountered: " " (32), after : "BIND"
    at com.hp.hpl.jena.sparql.lang.ParserSPARQL10.perform(ParserSPARQL10.java:95)
    at com.hp.hpl.jena.sparql.lang.ParserSPARQL10.parse(ParserSPARQL10.java:39)
    at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:129)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:72)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:43)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:31)
    at com.hp.hpl.jena.query.QueryExecutionFactory.sparqlService(QueryExecutionFactory.java:342)
    at com.ifour.testdata.AW317.QuerySampleDataSPARQL.main(QuerySampleDataSPARQL.java:28)

任何人都可以帮我解决一个我用Google搜索但没有找到解决方案的问题。同样的查询在virtuoso SPARQL端点上运行,给我完美的结果。但在使用java Jena SPARQL查询时,我收到此错误。

1 个答案:

答案 0 :(得分:0)

根据@AKSW的评论中的建议,答案是

更新至current Jena(可能是当前的Virtuoso服务器[无论Enterprise还是Open Source],Virtuoso Provider for Jena, and/or Virtuoso JDBC driver