The 400 is being generated by the server at http://localhost:8890/sparql. Jena is merely relaying the HTTP response to you. Maybe there is something in the server's logs.

        Andy

On 20/07/15 05:56, 朱曼 wrote:
Dear list,

I am interested in this query:
SELECT (COUNT(DISTINCT ?inst) AS ?count)
FROM <http://dbpedia.org>
WHERE {
?inst <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <
http://schema.org/Person>;
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <
http://dbpedia.org/ontology/Philosopher>.
}

If I query it in Virtuoso, for example http://dbpedia.org/sparql,
everything seems to be fine;
but when I am using the following code, I receive a "HttpException: 400 Bad
Request" exception (the detailed information are at the end ).

QueryExecutionFactory.sparqlService("http://localhost:8890/sparql","SELECT
(COUNT(DISTINCT ?inst) AS ?count)\n FROM <http://dbpedia.org>\n  WHERE { " +
"?inst <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <
http://schema.org/Person>;" +
" <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <
http://dbpedia.org/ontology/Philosopher>.}").execSelect();


Exception in thread "main" HttpException: HttpException: 400 Bad Request:
HttpException: 400 Bad Request
at
com.hp.hpl.jena.sparql.engine.http.HttpQuery.execCommon(HttpQuery.java:337)
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:189)
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:144)
at
com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:133)

Many thanks for your helps.

Best,

June


Reply via email to