1. You haven't followed the example. You are missing Syntax.syntaxARQ in QueryFactory.create(), I guess this makes a difference since CONSTRUCT with quads is not standard SPARQL.
2. Because INSERT is an update and not a query? Se UpdateFactory: https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/update/UpdateFactory.html On Wed, Nov 2, 2016 at 1:30 AM, Jason Koh <jb...@eng.ucsd.edu> wrote: > Dear all, > > This might be due to my lack of knowledge on SPARQL syntax. > > 1. > I try to construct a named graph via SPARQL query, but it fails. > so What I did is like following > /////////// > Model model = ModelFactory.createDefaultModel(); > String queryStr ="CONSTRUCT {GRAPH <http://example.com> {<s1> <p1> <o1>.} } > WHERE{}"; > Query query = QueryFactory.create(queryStr); > QueryExecution qe = QueryExecutionFactory.create(query, resultModel); > ///////// > > It fails at the third line while it is parsing with this error message: > Exception in thread "main" org.apache.jena.query.QueryParseException: > Encountered " "graph" "GRAPH "" at line 1, column 335. > > I am thinking that I am following > https://jena.apache.org/documentation/query/construct-quad.html correctly. > > Could you tell me the problem in the query? > > > 2. > Actually I rather want to use INSERT instead of CONSTRUCT, but QueryFactory > cannot parse INSERT. Why is that? > > Thanks! > > > With regards, > Jason Koh > cseweb.ucsd.edu/~jbkoh