I am trying to run a query using D2RQ. When I run the query using the browser from http://localhost:2020/sparql
as described in Using the D2RQ Engine with Jena, everything works fine, but with the Jena API it does not produce any results. The query is
PREFIX vocab: <http://localhost:2020/resource/vocab/>
SELECT ?personName WHERE {
?person vocab:people_Name ?personName .
}
Here the is Java code that constructs the query and runs it against a Model:
ModelD2RQ m = new ModelD2RQ( "file:///C:/Users/sabse/Downloads/d2rq-0.8.1/d2rq-0.8.1/mapping-ontology.ttl");
String sparql =
"PREFIX vocab: <http://localhost:2020/resource/vocab/>" +
"SELECT ?personName WHERE {" +
" ?person vocab:people_Name ?personName . " +
"}";
Query q = QueryFactory.create(sparql);
ResultSet rs = QueryExecutionFactory.create(q, m).execSelect();
ResultSetFormatter.out(System.out, rs, q);
m.close();
The data begins with the following prefix declarations:
@prefix vocab: <vocab/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#> .
@prefix jdbc: <http://d2rq.org/terms/jdbc/> .