Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Options for calling a sparql endpoint in jena

$
0
0
Hi All

Happy New Year.

I've previously used the following code with success to call a sparql
endpoint.
final com.hp.hpl.jena.query.QueryExecution qexec =
com.hp.hpl.jena.query.QueryExecutionFactory.sparqlService(serviceUri,query)

final com.hp.hpl.jena.query.ResultSet tempresults =
qexec.execSelect() ;

This works well and has allowed me seperate the endpoint url from the query.

I would now like to handle queries which define the service clause in them
and without having to set the service uri specifically.
e.g
select * where

SERVICE <sparqlepURL> {
.....

I can't find an exact code example but I did find the documentation about
using the Syntax.syntaxARQ.
But it didn't say how to use it.

So I tried the following
final com.hp.hpl.jena.query.QueryExecution qexec =
com.hp.hpl.jena.query.QueryExecutionFactory.create(query,com.hp.hpl.jena.query.Syntax.syntaxARQ)

final com.hp.hpl.jena.query.ResultSet results = qexec.execSelect() ;

This throws the error

com.hp.hpl.jena.query.QueryExecException: No dataset description for query
at
com.hp.hpl.jena.sparql.engine.QueryExecutionBase.prepareDataset(QueryExecutionBase.java:604)
at
com.hp.hpl.jena.sparql.engine.QueryExecutionBase.getPlan(QueryExecutionBase.java:547)
................

I'm a little confused as to how this make it work.
There is no dataset to search here as it is an endpoint.

If someone could suggest how to do this it would be appreciated

Sorry for the dumb question.

Phil

Viewing all articles
Browse latest Browse all 5648

Trending Articles