You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Elli Schwarz <el...@yahoo.com> on 2013/01/09 21:54:33 UTC

Re: Problem querying with sparqlService

Andy,

I just upgraded my pom files to point to the latest Jena snapshots (from this morning). While I can verify that JENA-361 is fixed for SELECT queries, I'm still having the problem for INSERT. So, this code doesn't work:

String updateString = "prefix ex: <http://example.org/> \n"
+ "with <urn:test:t1> \n" + "INSERT {?foo ex:foo ?obj} \n"
+ "WHERE { ?foo ex:prop1 [ \n"
+ "                          ex:prop2 ?o ;\n" 
+ "                          ex:prop3 ?obj ] "
+ "}";  
UpdateRequest update = UpdateFactory.create(updateString);
UpdateRemote.execute(update, "http://localhost:3030/ds/update"); //exception thrown here

I get this exception (truncated):
org.apache.jena.atlas.web.HttpException: 400 Encountered " "?" "? "" at line 9, column 5. Was expecting one of:  ...


If I don't use the bracket notation above, but explicitly create another variable instead of the [ ], it works fine. So it looks like the same problem as JENA-361, but for INSERT scripts. As before, this works fine if I use Fuseki directly.

(PS. Do you prefer me to report these kinds of issues in JIRA or using this mailing list?)

Thanks,
Elli


________________________________
 From: Andy Seaborne <an...@apache.org>
To: users@jena.apache.org 
Sent: Thursday, December 6, 2012 2:38 PM
Subject: Re: Problem querying with sparqlService
 
On 06/12/12 17:00, Andy Seaborne wrote:

> I've recorded this as:
>
> https://issues.apache.org/jira/browse/JENA-361

Wasn't as structural as I feared it might be.  Fixed in SVN.

    Andy

Re: How can I make a query using variable filter value

Posted by Andy Seaborne <an...@apache.org>.
On 12/01/13 11:22, iman paryudi wrote:
> I am trying to make a query using Jena ARQ as follows:
>
> static public final String NL = System.getProperty("line.separator") ;
>
> //some codes
>
> String prolog = "PREFIX rdf: <"+ RDF.getURI()+"> PREFIX rdfs: <"+RDFS.getURI()+"> PREFIX myproject: <http://www.myproject.com/ontologies/myproject.owl#>" ;
>
> String queryString = prolog + NL + "SELECT ?individu WHERE {?individu rdf:type myproject:Plant. ?individu myproject:height ?height.  FILTER(?height <= 6.0). ?individu myproject:diameter ?diameter. FILTER(?diameter = 0.5)} ORDER BY ?individu" ;
>
> //some codes
>
> Using this code my program works well. As we can see that I use constant filter values for height and diameter (6.0 and 0.5 respectively). However actually what I want is not a constant filter values. Instead I want variable filter values. This is similar to PreparedStatement in MySQL. I need this because the query must change dynamically based on user input.
> So, my question is: how can I make a query using variable filter value?
> Thanks.
>
> Iman Paryudi
>

See ParameterizedSparqlString or
QueryExecutionFcatory.create(... QuerySolution)

	Andy

How can I make a query using variable filter value

Posted by iman paryudi <su...@yahoo.com>.
I am trying to make a query using Jena ARQ as follows:

static public final String NL = System.getProperty("line.separator") ;

//some codes

String prolog = "PREFIX rdf: <"+ RDF.getURI()+"> PREFIX rdfs: <"+RDFS.getURI()+"> PREFIX myproject: <http://www.myproject.com/ontologies/myproject.owl#>" ;

String queryString = prolog + NL + "SELECT ?individu WHERE {?individu rdf:type myproject:Plant. ?individu myproject:height ?height.  FILTER(?height <= 6.0). ?individu myproject:diameter ?diameter. FILTER(?diameter = 0.5)} ORDER BY ?individu" ;

//some codes

Using this code my program works well. As we can see that I use constant filter values for height and diameter (6.0 and 0.5 respectively). However actually what I want is not a constant filter values. Instead I want variable filter values. This is similar to PreparedStatement in MySQL. I need this because the query must change dynamically based on user input.
So, my question is: how can I make a query using variable filter value?
Thanks.

Iman Paryudi

Re: Problem querying with sparqlService

Posted by Andy Seaborne <an...@apache.org>.
On 11/01/13 13:18, Elli Schwarz wrote:
> Andy,
>
> Yes, my tests pass now. Thank you!
>
> (I was waiting for the Maven repo to be updated before I tested this, and I didn't notice the update until this morning. How often does the SNAPSHOT repo get updated? Apparently, it doesn't happen every time you commit.)

https://builds.apache.org/view/G-L/view/Jena/

There are two builds

Jena__Development_Deploy
Jena__Development_Test

Deploy runs once a day (between 2 and 5 AM UTC - it's some randomized 
time to spread load) and uploads to the snapshots repo.  It polls SVn as 
well so no changes, no build.

It runs "mvn clean deploy"

Test polls SVN (every 10 mins? IIRC) and runs "mvn clean test" - no upload.

The test is supposed to catch system build error and they get fixed 
before deploy.  It sometimes takes a lot longer for "test" to actually 
run if the system is busy at the time.

The Jenkins build server isn't perfect - it's a complex beast and 
overloaded so builds break for config reasons, build slaves go 
offline,networks become congested, etc etc

All the builds email commits@jena.a.o on problems.

If you want to jump the wait , "svn update ; mvn clean install" locally!

	Andy


>
> -Elli
>
>
> ________________________________
>   From: Andy Seaborne <an...@apache.org>
> To: users@jena.apache.org
> Sent: Thursday, January 10, 2013 9:28 AM
> Subject: Re: Problem querying with sparqlService
>
> On 10/01/13 10:13, Andy Seaborne wrote:
>> On 09/01/13 20:54, Elli Schwarz wrote:
>>> Andy,
>>>
>>> I just upgraded my pom files to point to the latest Jena snapshots
>>> (from this morning). While I can verify that JENA-361 is fixed for
>>> SELECT queries, I'm still having the problem for INSERT. So, this code
>>> doesn't work:
>>>
>>> String updateString = "prefix ex: <http://example.org/> \n"
>>> + "with <urn:test:t1> \n" + "INSERT {?foo ex:foo ?obj} \n"
>>> + "WHERE { ?foo ex:prop1 [ \n"
>>> + "                          ex:prop2 ?o ;\n"
>>> + "                          ex:prop3 ?obj ] "
>>> + "}";
>>> UpdateRequest update = UpdateFactory.create(updateString);
>>> UpdateRemote.execute(update, "http://localhost:3030/ds/update");
>>> //exception thrown here
>>>
>>> I get this exception (truncated):
>>> org.apache.jena.atlas.web.HttpException: 400 Encountered " "?" "? ""
>>> at line 9, column 5. Was expecting one of:  ...
>>>
>>>
>>> If I don't use the bracket notation above, but explicitly create
>>> another variable instead of the [ ], it works fine. So it looks like
>>> the same problem as JENA-361, but for INSERT scripts. As before, this
>>> works fine if I use Fuseki directly.
>>>
>>> (PS. Do you prefer me to report these kinds of issues in JIRA or using
>>> this mailing list?)
>>
>> Either work for me - it's the "complete minimal example" that matters
>> most.  If things are an immediate fix and a bit "corner case", I don't
>> always raise a JIRA just to close it immediately, but generally having a
>> record in JIRA is good.
>>
>> I've opened a JIRA for this as I can't look at it right now.
>>
>> https://issues.apache.org/jira/browse/JENA-378
>
> Should be fixed now.  Similar sort of problem but different code error
> to the last time.
>
>      Andy
>
>>
>> Simple case:
>>
>> arq.uparse 'INSERT {} WHERE { ?x ?p [ ?a  ?b ] }'
>>
>> needs to be legal syntax and that command checks the whole cycle.
>>
>>        Andy
>>
>>>
>>> Thanks,
>>> Elli
>>


Re: Problem querying with sparqlService

Posted by Elli Schwarz <el...@yahoo.com>.
Andy,

Yes, my tests pass now. Thank you!

(I was waiting for the Maven repo to be updated before I tested this, and I didn't notice the update until this morning. How often does the SNAPSHOT repo get updated? Apparently, it doesn't happen every time you commit.)

-Elli


________________________________
 From: Andy Seaborne <an...@apache.org>
To: users@jena.apache.org 
Sent: Thursday, January 10, 2013 9:28 AM
Subject: Re: Problem querying with sparqlService
 
On 10/01/13 10:13, Andy Seaborne wrote:
> On 09/01/13 20:54, Elli Schwarz wrote:
>> Andy,
>>
>> I just upgraded my pom files to point to the latest Jena snapshots
>> (from this morning). While I can verify that JENA-361 is fixed for
>> SELECT queries, I'm still having the problem for INSERT. So, this code
>> doesn't work:
>>
>> String updateString = "prefix ex: <http://example.org/> \n"
>> + "with <urn:test:t1> \n" + "INSERT {?foo ex:foo ?obj} \n"
>> + "WHERE { ?foo ex:prop1 [ \n"
>> + "                          ex:prop2 ?o ;\n"
>> + "                          ex:prop3 ?obj ] "
>> + "}";
>> UpdateRequest update = UpdateFactory.create(updateString);
>> UpdateRemote.execute(update, "http://localhost:3030/ds/update");
>> //exception thrown here
>>
>> I get this exception (truncated):
>> org.apache.jena.atlas.web.HttpException: 400 Encountered " "?" "? ""
>> at line 9, column 5. Was expecting one of:  ...
>>
>>
>> If I don't use the bracket notation above, but explicitly create
>> another variable instead of the [ ], it works fine. So it looks like
>> the same problem as JENA-361, but for INSERT scripts. As before, this
>> works fine if I use Fuseki directly.
>>
>> (PS. Do you prefer me to report these kinds of issues in JIRA or using
>> this mailing list?)
>
> Either work for me - it's the "complete minimal example" that matters
> most.  If things are an immediate fix and a bit "corner case", I don't
> always raise a JIRA just to close it immediately, but generally having a
> record in JIRA is good.
>
> I've opened a JIRA for this as I can't look at it right now.
>
> https://issues.apache.org/jira/browse/JENA-378

Should be fixed now.  Similar sort of problem but different code error 
to the last time.

    Andy

>
> Simple case:
>
> arq.uparse 'INSERT {} WHERE { ?x ?p [ ?a  ?b ] }'
>
> needs to be legal syntax and that command checks the whole cycle.
>
>      Andy
>
>>
>> Thanks,
>> Elli
>

Re: Problem querying with sparqlService

Posted by Andy Seaborne <an...@apache.org>.
On 10/01/13 10:13, Andy Seaborne wrote:
> On 09/01/13 20:54, Elli Schwarz wrote:
>> Andy,
>>
>> I just upgraded my pom files to point to the latest Jena snapshots
>> (from this morning). While I can verify that JENA-361 is fixed for
>> SELECT queries, I'm still having the problem for INSERT. So, this code
>> doesn't work:
>>
>> String updateString = "prefix ex: <http://example.org/> \n"
>> + "with <urn:test:t1> \n" + "INSERT {?foo ex:foo ?obj} \n"
>> + "WHERE { ?foo ex:prop1 [ \n"
>> + "                          ex:prop2 ?o ;\n"
>> + "                          ex:prop3 ?obj ] "
>> + "}";
>> UpdateRequest update = UpdateFactory.create(updateString);
>> UpdateRemote.execute(update, "http://localhost:3030/ds/update");
>> //exception thrown here
>>
>> I get this exception (truncated):
>> org.apache.jena.atlas.web.HttpException: 400 Encountered " "?" "? ""
>> at line 9, column 5. Was expecting one of:  ...
>>
>>
>> If I don't use the bracket notation above, but explicitly create
>> another variable instead of the [ ], it works fine. So it looks like
>> the same problem as JENA-361, but for INSERT scripts. As before, this
>> works fine if I use Fuseki directly.
>>
>> (PS. Do you prefer me to report these kinds of issues in JIRA or using
>> this mailing list?)
>
> Either work for me - it's the "complete minimal example" that matters
> most.  If things are an immediate fix and a bit "corner case", I don't
> always raise a JIRA just to close it immediately, but generally having a
> record in JIRA is good.
>
> I've opened a JIRA for this as I can't look at it right now.
>
> https://issues.apache.org/jira/browse/JENA-378

Should be fixed now.  Similar sort of problem but different code error 
to the last time.

	Andy

>
> Simple case:
>
> arq.uparse 'INSERT {} WHERE { ?x ?p [ ?a  ?b ] }'
>
> needs to be legal syntax and that command checks the whole cycle.
>
>      Andy
>
>>
>> Thanks,
>> Elli
>


Re: Problem querying with sparqlService

Posted by Andy Seaborne <an...@apache.org>.
On 09/01/13 20:54, Elli Schwarz wrote:
> Andy,
>
> I just upgraded my pom files to point to the latest Jena snapshots (from this morning). While I can verify that JENA-361 is fixed for SELECT queries, I'm still having the problem for INSERT. So, this code doesn't work:
>
> String updateString = "prefix ex: <http://example.org/> \n"
> + "with <urn:test:t1> \n" + "INSERT {?foo ex:foo ?obj} \n"
> + "WHERE { ?foo ex:prop1 [ \n"
> + "                          ex:prop2 ?o ;\n"
> + "                          ex:prop3 ?obj ] "
> + "}";
> UpdateRequest update = UpdateFactory.create(updateString);
> UpdateRemote.execute(update, "http://localhost:3030/ds/update"); //exception thrown here
>
> I get this exception (truncated):
> org.apache.jena.atlas.web.HttpException: 400 Encountered " "?" "? "" at line 9, column 5. Was expecting one of:  ...
>
>
> If I don't use the bracket notation above, but explicitly create another variable instead of the [ ], it works fine. So it looks like the same problem as JENA-361, but for INSERT scripts. As before, this works fine if I use Fuseki directly.
>
> (PS. Do you prefer me to report these kinds of issues in JIRA or using this mailing list?)

Either work for me - it's the "complete minimal example" that matters 
most.  If things are an immediate fix and a bit "corner case", I don't 
always raise a JIRA just to close it immediately, but generally having a 
record in JIRA is good.

I've opened a JIRA for this as I can't look at it right now.

https://issues.apache.org/jira/browse/JENA-378

Simple case:

arq.uparse 'INSERT {} WHERE { ?x ?p [ ?a  ?b ] }'

needs to be legal syntax and that command checks the whole cycle.

	Andy

>
> Thanks,
> Elli