LongStreak
LongStreak

Reputation: 111

Insert via remote HTTP/SPARQL in Jena - Spring Boot 3

I am looking for a way to construct a SPARQL insert query in Jena, and upload it to a remote SPARQL endpoint (served by Virtuoso's Open Edition, if it matters). Most of the documentation references this now-deprecated pattern, which I can't seem to configure.

String insertQuery = "INSERT DATA { GRAPH <urn:core:services:sparql> { " +
           serializedData +
       "} }";
// Create a Virtuoso-specific UpdateRequest
UpdateRequest updateRequest = UpdateFactory.create(insertQuery);

// Create a Virtuoso-specific UpdateProcessor
UpdateProcessor updateProcessor = UpdateExecutionFactory.createRemote(updateRequest, virtuosoUrl);

I have managed this in python/RDFLib by building a local graph, and extracting the triples/constructing a query and using the SPARQLWrapper, something like:

sparql = SPARQLWrapper(virtuoso_url)
sparql.method = 'POST'
sparql.setQuery(query_start+query_body+query_end)
sparql.query()

What would be a/the correct way to do this in Java? Thank you.

Upvotes: 1

Views: 85

Answers (0)

Related Questions