-1

the code is for querying dbpedia from java program and then displaying the result in html page

package jenaamem;

import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;

public class db2
{
static public void main(String...argv)
{
    try {
        String queryStr = "SELECT * WHERE{ ?s ?p ?o . ?o bif:contains' barack and obama and america' OPTION (score ?sc) } ORDER BY DESC (?sc) LIMIT 10 ";
        Query query = QueryFactory.create(queryStr);

        // Remote execution.
        QueryExecution qexec =   QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
        // Set the DBpedia specific timeout.
        ((QueryEngineHTTP)qexec).addParam("timeout", "10000") ;

        // Execute.
        ResultSet rs = qexec.execSelect();
        ResultSetFormatter.out(System.out, rs, query);
        qexec.close();
    } catch (Exception e) {
    }


}

}

here the problem i am facing in this code is that bif:contains is showing error, i even tried then also my problem continues.

Roger Rowland
  • 25,885
  • 11
  • 72
  • 113
user2257125
  • 1
  • 1
  • 3

1 Answers1

3

bif:contains is a prefixed name but you haven't defined a prefix for it so the ARQ parser throws an error as it should

Unfortunately bif:contains is a Virtuoso specific extension and doesn't actually have any associated prefix so you can't define it. However you can enclose it in < and > so that ARQ treats it like a URI and Virtuoso will still understand it i.e. use <bif:contains> in your query instead.

RobV
  • 28,022
  • 11
  • 77
  • 119
  • sir i tried but the problem remains as it is. is there any way to directly pass query to virtuoso without allowing jena to parse the query and then interfere it – user2257125 Apr 08 '13 at 17:06