Kathi
Kathi

Reputation: 21

SPARQL insert query and create query don't work via SPARQLRepository and GraphDB

I use a GraphDB Repository and want to execute some querys via Java using SPARQLRepository. It works fine when I just read with the Queries. But when I have a query "Create graph :example" or an insert and delete query, it doesn't work. When I execute the Queries via the GraphDB UI, it works fine. The doku of SPARQLRepository says I need a second endpoint which is according to the GraphDB doku the same with "/statements" in the end. So in my code it looks like this:

String repositoryUrl = "http://localhost:7200/repositories/test";
SPARQLRepository repository = new SPARQLRepository(repositoryUrl, repositoryUrl + "/statements");

I can execute a reading query with this but when I want to execute a query that creates a new graph, it says

15:12:12.108 [main] WARN  o.e.r.h.c.SharedHttpClientSessionManager$3 - Server reports problem: Encountered " "create" "CREATE "" at line 1, column 1.
Was expecting one of:
    "base" ...
    "prefix" ...
    "select" ...
    "construct" ...
    "describe" ...
    "ask" ...

Can anybody help me? Thanks.

Upvotes: 0

Views: 316

Answers (1)

Kathi
Kathi

Reputation: 21

The problem was that I used prepareQuery instead of prepareUpdate. Thank you so much! Now it works.

Upvotes: 1

Related Questions