Andy, thank you very much!

BTW,  Jena documentation is not very detailed...

Thanks.

Vadim.


On Tue, May 3, 2016 at 12:50 PM, Andy Seaborne <[email protected]> wrote:

> Hi Vadim,
>
> A SPARQL query runs against a dataset and that what your created with the
> N-Quads files.
>
> But a dataset is not a model.
>
> A model is just one graph.
>
> Read the remote data into a dataset with:
>
>
>     Dataset ds = RDFDataMgr.loadDataset(url) ;
> ...
>
>     QueryExecutionFactory.create(query, ds);
> ...
>
> What is happening is that at:
>    model.read(url);
>  only the default graph of the dataset at "http://localhost:3030/ds"; is
> put in the model.  Models are graphs (the name reflects the older 2004 RDF
> terminology)
>
>     Andy
>
>
> On 03/05/16 07:36, Vadim Shumilin wrote:
>
>> 1) I use Fuseki2.
>>
>> 2) I have same test data
>> a) as triples in rdf file
>> b) as quads in nq file with graph name
>>
>> from browser -- http://localhost:3030
>> -  I uploaded the data to persistent dataset
>> -  I see that my data successfully stored.
>> -  I performed simple queries
>>
>>    #1)
>>         SELECT ?subj ?pred ?obj WHERE { ?subj ?pred ?obj }
>>    #2)
>>         SELECT ?subj ?pred ?obj WHERE {
>>             GRAPH ?g  { ?subj ?pred ?obj }
>>         }
>>
>>    both queries succeeded and I saw valid results.
>>
>>
>> OK, now I try to perform same queries from java program.
>> Here is my code:
>>
>>      Model model = ModelFactory.createDefaultModel();
>>      String url = "http://localhost:3030/ds";;
>>      model.read(url);
>>
>>      String RQuery = ...;  //// <<< query #1 or query #2
>>
>>      Query query = QueryFactory.create(RQuery);
>>      QueryExecution qe = QueryExecutionFactory.create(query, model);
>>
>>      ResultSet rs = qe.execSelect();
>>      int count=0;
>>
>>      while (rs.hasNext())
>>      {
>>        QuerySolution qsol = rs.nextSolution();
>>        ++count;
>>      }
>>
>> And I have proper count for query #1 and count==0 for query #2.
>>
>> Please, what is wrong with my code.
>>
>> Thanks.
>>
>>
>>
>>
>>
>>
>>
>>
>


-- 
Vadim Shumilin

Reply via email to