0

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.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73
Kathi
  • 21
  • 5
  • 1
    Can you share the query? It seems that you are trying to insert invalid sparql. – Konstantin Petrov Jan 16 '20 at 14:43
  • did you use `prepareUpdate` on the `RepositoryConnection` object? Instead `prepareQuery` – UninformedUser Jan 16 '20 at 15:48
  • also ,what's the purpose of creating the graph? For me this sounds unnecessary as no graph can exist without data – UninformedUser Jan 16 '20 at 15:50
  • Can you show the query / update and the code you use to execute it please? You can [edit] your question to add the necessary details for us to reproduce the problem. Also: have a look at [ask] for more tips on how to write questions that have a high chance of getting a good answer. – Jeen Broekstra Jan 16 '20 at 22:53

1 Answers1

1

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

Kathi
  • 21
  • 5