Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] Java/Jena example 500 error

Celeste, Michael michael.celeste at pfizer.com
Fri Oct 18 03:22:16 PDT 2013


Hello,

I am trying to run the java file using Jena below after supplying my apikey but I keep getting an HTTP 500 error. I also tried adding a query parameter but get the same error.
Thanks,
Michael

package businessdevelopment;

import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;

/**
* This is an example built on top of the Jena ARQ library.
* See: http://jena.sourceforge.net/ARQ/documentation.html
*/
public class JenaARQTest {

        private String service = null;
        private String apikey = null;

        public JenaARQTest(String service, String apikey) {
                this.service = service;
                this.apikey = apikey;
        }
        public ResultSet executeQuery(String queryString) throws Exception {
                 Query query = QueryFactory.create(queryString) ;

                 QueryEngineHTTP qexec = QueryExecutionFactory.createServiceRequest(this.service, query);
                 qexec.addParam("apikey", this.apikey);
                 //qexec.addParam("query", queryString);
                 ResultSet results = qexec.execSelect() ;
                 return results;

        }
        public static void main(String[] args) throws Exception {
                String sparqlService = "http://sparql.bioontology.org/sparql";
                String apikey = "81ac8eba-12ca-4b94-a80f-82e4cfd2291a";

                /*
                 * More query examples here:
                 * http://sparql.bioontology.org/examples
                 */
                String query = "PREFIX omv: <http://omv.ontoware.org/2005/05/ontology#> " +
                                           "SELECT ?ont ?name ?acr " +
                                           "WHERE { ?ont a omv:Ontology; " +
                                           "omv:acronym ?acr; " +
                                           "omv:name ?name . " +
                                           "}";
                try {
                JenaARQTest test = new JenaARQTest(sparqlService,apikey);
                ResultSet results = test.executeQuery(query);
                    for ( ; results.hasNext() ; ) {
                      QuerySolution soln = results.nextSolution() ;
                      RDFNode ontUri = soln.get("ont") ;
                      Literal name = soln.getLiteral("name") ;
                      Literal acr = soln.getLiteral("acr") ;
                      System.out.println(ontUri + " ---- " + name + " ---- " + acr);
                    }
                }
                catch(Exception e) {
                  System.out.println(e);
                }
        }
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/bioontology-support/attachments/20131018/3739eb12/attachment-0001.html>


More information about the bioontology-support mailing list