HttpException-Fehler beim Aufrufen einer SPARQL-Abfrage (in DBPedia) in Java-Code

Ich habe ein Problem mit SPARQL-Endpunkten, die Java-Code verwenden.

Insbesondere habe ich diese Java-Klasse:

public class example {

    public static void main(String[] args) {

        String value = "http://dbpedia.org/resource/Fred_Guy";

        example exam = example();
        QueryExecution qe = exam.query(value);
        ResultSet results = ResultSetFactory.copyResults( qe.execSelect() );

    }


    public QueryExecution query(String stringa){

        ParameterizedSparqlString qs = new ParameterizedSparqlString( "" +
                "prefix dbpediaont: <http://dbpedia.org/ontology/>\n" +
                "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
                "\n" +  
                "select ?resource where {\n" +
                "?mat rdf:type ?resource\n" +
                "filter strstarts(str(?resource), dbpediaont:)\n" +
                "}" );


        Resource risorsa = ResourceFactory.createResource(stringa);
        qs.setParam( "mat", risorsa );

        QueryExecution exec = QueryExecutionFactory.sparqlService( "http://dbpedia.org/sparql", qs.asQuery() );

        ResultSet results = ResultSetFactory.copyResults( exec.execSelect() );

        while ( results.hasNext() ) {

            System.out.println( results.next().get( "resource" ));
        }

        // A simpler way of printing the results.
        ResultSetFormatter.out( results );

        return exec;
    }
}

Ich möchte die Objekte der Ressource abrufen. "http://dbpedia.org/resource/Fred_Guy"dessen Prädikat" RDF: Typ ". Aber ich habe diesen Fehler, den ich nicht verstehe:

Exception in thread "main" HttpException: 500
    at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:340)
    at com.hp.hpl.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:276)
    at com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:345)
    at MyPackage.example.main(example.java:19)

Warum bekomme ich diesen Fehler?

Ich versuche, diese Abfrage auszuführen

"http://dbpedia.org/sparql"

ohne strstarts zu schreiben bekomme ich diesen fehler:

Virtuoso 37000 Error SP031: SPARQL compiler: No one quad map pattern is suitable for GRAPH <http://dbpedia.org> { "http://dbpedia.org/resource/Fred_Guy" <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?resource } triple at line 7

SPARQL query:
define sql:big-data-const 0 
#output-format:text/html
define sql:signal-void-variables 1 define input:default-graph-uri <http://dbpedia.org> prefix dbpediaont: <http://dbpedia.org/ontology/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select ?resource where {
"http://dbpedia.org/resource/Fred_Guy" rdf:type ?resource
}

Was mache ich hier falsch?

Ich habe versucht, diesen Code in Virtuoso zu schreiben:

prefix dbpediaont: <http://dbpedia.org/ontology/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select ?resource where {
dbpedia:Fred_Guy rdf:type ?resource
}

SPARQL-Ergebnisse

Wie kann ich es in Jenaer Code schreiben?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage