Sparql query doesn't return results using Fuseki

73 Views Asked by At

I am trying to run a sparql query via fuseki using java. The fuseki server is running. However when I run the code below, I can see that the console in eclipse is running but no results are returned (just blank console).

I am using Fuseki 4.7.0, Jena 4.7.0 and Java 11.

The dataset "your-dataset" is created using the following command:

fuseki-server --loc=data --update /your-dataset

Code that I used is the following:

package test;

import org.apache.jena.query.Query; 
import org.apache.jena.query.QueryExecution; 
import org.apache.jena.query.QueryFactory; 
import org.apache.jena.query.ResultSet; 

public class QueryStore {

    public static void main(final String[] args) throws Exception { 
    

    String queryString=
            "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
            "prefix owl: <http://www.w3.org/2002/07/owl#>"+

            "SELECT ?subject ?predicate ?object"+
            "WHERE {"+
            " ?subject ?predicate ?object"+
            " } LIMIT 25";

            Query query = QueryFactory.create(queryString);
   
            QueryExecution qexec = QueryExecution.service("http://localhost:3030/your-dataset/sparql").query(query).build();

            
            ResultSet results = qexec.execSelect();
            if (results.hasNext())
            {
                System.out.print(results.next().toString());
            }
            else {
                System.out.print("empty dataset");
            }
                
    }
}

Can you spot what did I do wrong?

0

There are 0 best solutions below