HI,
What does the Fuseki log say? No message in the Fuseki log. Before running the main program, I execute this command first " ruby s-put http://localhost:3030/ds2/data default per2.owl" to put the file in the server. What's in model at this point? Simultaneously I am writing the file to local c drive also. For that I used in model. Also I changed the first line of rupdata to #!/bin/sh instead of #!/bin/bash. Fuseki log after running the server D:\fuseki-0.2.2>run D:\fuseki-0.2.2>java -Xmx1200M -jar fuseki-server.jar --update --mem --loc=D:/fu seki-0.2.2/TD /ds2 10:40:16 INFO Server :: Dataset: in-memory 10:40:16 INFO Server :: TDB dataset: directory=D:/fuseki-0.2.2/TD 10:40:17 INFO Server :: Dataset path = /ds2 10:40:17 INFO Server :: Fuseki 0.2.2-incubating-SNAPSHOT 20120506 -0501 10:40:17 INFO Server :: Jetty 7.x.y-SNAPSHOT 10:40:17 INFO Server :: Started 2012/06/11 10:40:17 PDT on port 3 030 10:48:03 INFO Fuseki :: [1] PUT http://localhost:3030/ds2/data?de fault 10:48:03 INFO Fuseki :: [1] 204 No Content 10:54:10 INFO Fuseki :: [3] GET http://localhost:3030/ds2/query?q uery=SELECT+%2A%7B%3Fs+%3Fp+%3Fo%7D 10:54:10 INFO Fuseki :: [3] Query = SELECT *{?s ?p ?o} 10:54:11 INFO Fuseki :: [3] OK/select 10:54:11 INFO Fuseki :: [3] 200 OK Here is the code static final String inputFileName = "http://localhost:3030/"; public static void main(String[] args) throws IOException{ Model model =ModelFactory.createOntologyModel(); // use the FileManager to find the input file InputStream in = FileManager.get().open(inputFileName); if (in == null) { throw new IllegalArgumentException( "File: " + inputFileName + " not found"); } model.read(inputFileName+"per2.owl"); in.close(); String queryString ="PREFIX xmlns: <http://localhost:3030/per1.owl#>\r\n" + "PREFIX base: <http://localhost:3030/per1.owl >\r"+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\r"+ "INSERT DATA" + "{"+ "<http://localhost:3030/per1.owl#name1>\n" + "xmlns:hasFirstname \" Xie\"^^ xsd:string;" + "}"; String queryString1 = "PREFIX owl: <http://localhost:3030/per1.owl#>" + "SELECT * "+ "FROM <http://localhost:3030/per1.owl>"+ "WHERE"+ "{"+ "?Name owl:hasFirstname ?hasFirstname." + "}"; GraphStore gs=GraphStoreFactory.create(model); gs.setDefaultGraph(model.getGraph()); UpdateRequest ur = UpdateFactory.create(queryString); Update update = ur.getOperations().get(0); UpdateExecutionFactory.createRemote(ur," http://localhost:3030/ds2/update"); UpdateAction.execute(ur,gs); System.out.println(update); // search part Query query = QueryFactory.create(queryString1); QueryExecution qe = QueryExecutionFactory.create(query, model); ResultSet results = qe.execSelect(); ResultSetFormatter.out(System.out, results, query); FileOutputStream fileour =new FileOutputStream("c:/per2.owl"); model.write(fileour,"RDF/XML-ABBREV"); qe.close(); } } Still struggling to write the file using UpdateExecutionFactory.createRemote Regards ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On Fri, Jun 8, 2012 at 2:34 AM, Andy Seaborne <[email protected]> wrote: > On 08/06/12 09:30, Don S wrote: > >> HI, >> >> Finally I succeed to call the >> function UpdateExecutionFactory.**createRemote. Thanks for the comments. >> >> Here is my configuration >> >> Fuseki server >> java -Xmx1200M -jar fuseki-server.jar --update --mem >> --loc=D:/fuseki-0.2.2/TD /ds2 >> >> and the insert query code >> >> public class search { >> static final String inputFileName = "http://localhost:3030/"; >> public static void main(String[] args) throws IOException{ >> Model model =ModelFactory.**createOntologyModel(); >> >> // use the FileManager to find the input file >> InputStream in = FileManager.get().open(**inputFileName); >> if (in == null) { >> throw new IllegalArgumentException( "File: " + inputFileName + >> " not found"); >> } >> >> model.read(inputFileName+"**per2.owl"); >> in.close(); >> > > What's in model at this point? > > > String queryString ="PREFIX xmlns: >> <http://localhost:3030/per1.**owl# <http://localhost:3030/per1.owl#> >> >\r\n" >> + >> "PREFIX base:<http://localhost:3030/** >> per1.owl <http://localhost:3030/per1.owl> >> >>> \r"+ >>> >> "PREFIX >> xsd:<http://www.w3.org/2001/**XMLSchema#<http://www.w3.org/2001/XMLSchema#> >> >\r"+ >> "INSERT DATA" + >> "{"+ >> >> "<http://localhost:3030/per1.**owl#name1<http://localhost:3030/per1.owl#name1>>\n" >> + >> "xmlns:hasFirstname \"Rex\"^^ xsd:string;" + >> "}"; >> > > xmlns is not a good choice of prefix name. > > > >> GraphStore gs=GraphStoreFactory.create(**model); >> gs.setDefaultGraph(model.**getGraph()); >> UpdateRequest ur = UpdateFactory.create(**queryString); >> Update update = ur.getOperations().get(0); >> UpdateExecutionFactory.**createRemote(ur," >> http://localhost:3030/per2.owl**"); >> UpdateAction.execute(ur,gs); >> System.out.println(update); >> >> >> // some codes .... >> >> qe.close(); >> } >> } >> >> I am wondering why it is not updating the ontology?? >> >> regards >> > > What does the Fuseki log say? > > > > UpdateExecutionFactory.**createRemote(ur,"http://**localhost:3030/per2.owl<http://localhost:3030/per2.owl> > "); > > > per2.owl is not a SPARQL update service endpoint. > > http://localhost:3030/ds2/**update <http://localhost:3030/ds2/update> is > the SPARQL update service endpoint. > > Andy >
