DBpedia的耶拿查询返回null(DBpedia Jena Query returning nu

2019-07-28 13:39发布

我只是想上运行DBpedia中,本身的工作原理查询小查询,看到它在这里 ,但我不知道为什么它的归国与耶拿这样做的时候,我得到空。

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"));
}

任何建议?

Answer 1:

就是这样尴尬的,有查询空间的问题:

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')"+
            "}";


文章来源: DBpedia Jena Query returning null