javaspring-bootsparqljenafuseki

insert data to Fuseki with sparql query


I am trying to insert new data to Fuseki through SPARQL query, it's giving me success(200 OK) but it's not showing in my TDB. and I think it's because I haven't defined to which graph but I don't know-how

    String queryString =          
          "PREFIX ns:<http://www.semanticweb.org/hightech/ontologies/2019/unit#>" 
                    + "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>" 
                    + "INSERT DATA{" 
                    + "ns:" + d.getDomainName()+ "ns:domainName " + d.getDomainName() + "." 
                    + "ns:" + d.getDomainName() + " ns:domainId "+ d.getDomainId() + "." 
                    + "}";

            UpdateRequest request = UpdateFactory.create(queryString);
            UpdateProcessor qe = UpdateExecutionFactory.createRemote(request,
                    "http://localhost:3030/eduDataSet/update");
            qe.execute();
        

Solution

  • try to reformat your queryString as shown in this picture.

    enter image description here

    reference

    be careful where to close your subject
    "PREFIX ns:<http://www.semanticweb.org/hightech/ontologies/2019/unit#>" <== is already closed, while you need to insert your d.getDomainName() before closing ">"