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.

asked 12 Jan '13, 06:15

Iman's gravatar image

accept rate: 0%

edited 17 May '13, 10:35

fellahst's gravatar image


(answer copied over from [email protected])

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

permanent link

answered 12 Jan '13, 12:23

AndyS's gravatar image

AndyS ♦
accept rate: 33%

I personally think that in this situation if you have to make query using variable filter value you can build the query dynamically.

same day delivery

permanent link

answered 17 May '13, 05:27

msmith's gravatar image

accept rate: 0%

edited 17 May '13, 05:33

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 12 Jan '13, 06:15

question was seen: 1,286 times

last updated: 17 May '13, 10:35