Reputation: 311
I'm trying to query Factforge Sparql endpoint with RDF4J but I receive an error.
I use RDF4J V: 2.3.2 with Maven.
I set my proxy settings on Java with:
System.setProperty("https.proxyHost", PROXY_HOST);
System.setProperty("https.proxyPort", PROXY_PORT);
System.setProperty("http.proxyHost", PROXY_HOST);
System.setProperty("http.proxyPort", PROXY_PORT);
Here is my code:
SPARQLRepository repo = new SPARQLRepository("http://factforge.net/sparql");
repo.initialize();
try (RepositoryConnection conn = repo.getConnection()) {
String queryStringA = "SELECT ?s ?p WHERE { ?s ?p ?o } ";
TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryStringA);
try (TupleQueryResult result = query.evaluate()) {
while (result.hasNext()) { // iterate over the result
BindingSet bindingSet = result.next();
Value valueOfX = bindingSet.getValue("s");
Value valueOfY = bindingSet.getValue("p");
System.out.println(valueOfX);
System.out.println(valueOfY);
}
}
}
I get the following error:
Exception in thread "main" org.eclipse.rdf4j.query.QueryEvaluationException: Failed to get server protocol; no such resource on this server: http://factforge.net/sparql?query=SELECT+%3Fs+%3Fp+WHERE+%7B+%3Fs+%3Fp+%3Fo+%7D+
I would appreciate a help. Thank you.
Upvotes: 1
Views: 174
Reputation: 22042
You're using the wrong endpoint URL. According to the Factforge overview, the SPARQL endpoint for Factforge is at http://factforge.net/repositories/ff-news
.
Apart from that, please note that the query you're doing is "give me ALL your triples". Factforge has a lot of triples, so the result of this is going to be massive, and executing it will consume a lot of resources on the Factforge server. Your query might time out or Factforge might refuse to execute it.
If your aim is simply to test that SPARQL querying works, it would be better to put something like a LIMIT
constraint in there:
String queryStringA = "SELECT ?s ?p WHERE { ?s ?p ?o } LIMIT 10";
Upvotes: 2