I'm just trying to run a small query on DBpedia, the query itself works, see it here , but I don't why its returning when doing so with Jena, I'm getting null.
String service = "http://dbpedia.org/sparql";
String queryString = "";
queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label" +
"WHERE {" +
"<http://dbpedia.org/resource/Quatre_Bornes> <http://dbpedia.org/ontology/country> ?y ."+
"?y rdfs:label ?label ."+
"FILTER (LANG(?label) = 'en')"+
"}";
Query query = QueryFactory.create(queryString);
QueryEngineHTTP qexec = QueryExecutionFactory.createServiceRequest(service, query);
ResultSet results = qexec.execSelect();
for ( ; results.hasNext() ; ) {
QuerySolution soln = results.nextSolution() ;
System.out.println(soln.getLiteral("label"));
}
Any suggestion?
that is so embarassing, there is space problem in the query:
String service = "http://dbpedia.org/sparql";
String queryString = "";
queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label " +
"WHERE {" +
"<http://dbpedia.org/resource/Quatre_Bornes> <http://dbpedia.org/ontology/country> ?y ."+
"?y rdfs:label ?label ."+
"FILTER (LANG(?label) = 'en')"+
"}";
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.