Hi All,
I have encountered a problem when using Jena. The query can be executed on http://dbpedia.org/sparql/ correctly, but failed in Java code.
Could anyone help me? I tried find solution online but failed. Some links said it's the version problem, but I think 2.11.2 is new.
Here's the code
String QueryOrg= "select distinct ?Apro (count(distinct ?n0) as ?Num) " +
"where{ " +
"?n0 a <http://dbpedia.org/ontology/TelevisionStation>. " +
"?n0 a <http://dbpedia.org/class/yago/CBSNetworkAffiliates>. " +
"?n0 ?Apro ?o. " +
"FILTER IsLiteral(?o) " +
"} " +
"group by ?Apro " +
"having(count(distinct ?n0) as ?tt >1) " +
"order by DESC(?Num) " ;
Query query = QueryFactory.create(QueryOrg);
// I have not do anything yet
The error:
"Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Encountered " "as" "as "" at line 1, column 260.
Was expecting one of:
"not" ...
"in" ...
<INTEGER_POSITIVE> ...
<DECIMAL_POSITIVE> ...
<DOUBLE_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE_NEGATIVE> ...
")" ...
"=" ...
"!=" ...
">" ...
"<" ...
"<=" ...
">=" ...
"||" ...
"&&" ...
"+" ...
"-" ...
"*" ...
"/" ...
at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:102)
at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:37)
at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:156)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:79)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:52)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
...
Thank you very much for your time.
Best Regards,
Wei
I have encountered a problem when using Jena. The query can be executed on http://dbpedia.org/sparql/ correctly, but failed in Java code.
Could anyone help me? I tried find solution online but failed. Some links said it's the version problem, but I think 2.11.2 is new.
Here's the code
String QueryOrg= "select distinct ?Apro (count(distinct ?n0) as ?Num) " +
"where{ " +
"?n0 a <http://dbpedia.org/ontology/TelevisionStation>. " +
"?n0 a <http://dbpedia.org/class/yago/CBSNetworkAffiliates>. " +
"?n0 ?Apro ?o. " +
"FILTER IsLiteral(?o) " +
"} " +
"group by ?Apro " +
"having(count(distinct ?n0) as ?tt >1) " +
"order by DESC(?Num) " ;
Query query = QueryFactory.create(QueryOrg);
// I have not do anything yet
The error:
"Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Encountered " "as" "as "" at line 1, column 260.
Was expecting one of:
"not" ...
"in" ...
<INTEGER_POSITIVE> ...
<DECIMAL_POSITIVE> ...
<DOUBLE_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE_NEGATIVE> ...
")" ...
"=" ...
"!=" ...
">" ...
"<" ...
"<=" ...
">=" ...
"||" ...
"&&" ...
"+" ...
"-" ...
"*" ...
"/" ...
at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:102)
at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:37)
at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:156)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:79)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:52)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
...
Thank you very much for your time.
Best Regards,
Wei