When I run this code in java I am getting error, I think the error occurred because of "String values". I am not sure about adding it but I got this idea from my previous question's answer which I asked in this site Query DBpedia to get abstract for different inputs
public static void DbpediaResultSparql() {
String values = "New York";
String service = "http://dbpedia.org/sparql";
String sparqlQueryString2 = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
"PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>"+
"PREFIX dbpedia: <http://dbpedia.org/resource/>"+
"SELECT DISTINCT ?abstract"+
"WHERE"+
"{ _:b0 rdfs:label ?name ."+
"_:b0 dbpedia-owl:abstract ?abstract"+
"FILTER langMatches(lang(?abstract), 'en')"+
"?name { " + values +" @en }"+
"}" ;
Query query = QueryFactory.create(sparqlQueryString2);
ARQ.getContext().setTrue(ARQ.useSAX);
// Executing SPARQL Query and pointing to the DBpedia SPARQL Endpoint
QueryExecution qexec = QueryExecutionFactory.sparqlService(
"http://DBpedia.org/sparql", query);
// Retrieving the SPARQL Query results
ResultSet results = qexec.execSelect();
// Iterating over the SPARQL Query results
while (results.hasNext()) {
QuerySolution soln = results.nextSolution();
// Printing DBpedia entries' abstract.
System.out.println(soln.get("?abstract"));
}
qexec.close();
}