You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2021/09/24 09:23:57 UTC

[GitHub] [jena] afs commented on a change in pull request #1030: SPARQL operations

afs commented on a change in pull request #1030:
URL: https://github.com/apache/jena/pull/1030#discussion_r715457593



##########
File path: jena-arq/src-examples/arq/examples/ExampleDBpedia2.java
##########
@@ -18,22 +18,28 @@
 
 package arq.examples;
 
-import org.apache.jena.query.* ;
-import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.query.*;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.util.Context;
 
 public class ExampleDBpedia2
 {
-    static public void main(String... argv) {
-        String queryString = 
-            "SELECT * WHERE { " +
-            "    SERVICE <http://dbpedia-live.openlinksw.com/sparql?timeout=2000> { " +
-            "        SELECT DISTINCT ?company where {?company a <http://dbpedia.org/ontology/Company>} LIMIT 20" +
-            "    }" +
-            "}" ;
-        Query query = QueryFactory.create(queryString) ;
-        try (QueryExecution qexec = QueryExecutionFactory.create(query, ModelFactory.createDefaultModel())) {
-            ResultSet rs = qexec.execSelect() ;
-            ResultSetFormatter.out(System.out, rs, query) ;
+    static public void main(String...argv)
+    {
+        String queryStr = "select distinct ?Concept where {[] a ?Concept} LIMIT 10";
+        Query query = QueryFactory.create(queryStr);
+
+        Context cxt = ARQ.getContext().copy();
+
+        // Build-execute
+        try ( QueryExecution qExec = QueryExecutionHTTP.create()
+                    .endpoint("http://dbpedia.org/sparql")
+                    .query(query)
+                    .param("timeout", "10000")
+                    .build() ) {
+          // Execute.
+          ResultSet rs = qExec.execSelect();
+          ResultSetFormatter.out(System.out, rs, query);

Review comment:
       Tabs be gone!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org