Advertisement
pipian

Jena Example 2

Aug 30th, 2012
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package org.example.simplejenaexample;
  2.  
  3. import com.hp.hpl.jena.query.QuerySolution;
  4. import com.hp.hpl.jena.query.ResultSet;
  5. import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
  6.  
  7. public class Main {
  8.  
  9.     /**
  10.      * @param args
  11.      */
  12.     public static void main(String[] args) {
  13.         QueryEngineHTTP qe = new QueryEngineHTTP(
  14.                 "http://geneid.bio2rdf.org/sparql",
  15.                 "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +
  16.                 "SELECT ?geneLabel WHERE { "
  17.                 + "?gene <http://bio2rdf.org/geneid_vocabulary:has_taxid> <http://bio2rdf.org/taxon:7955> . "
  18.                 + "?gene <http://bio2rdf.org/geneid_vocabulary:has_chromosome> \"1\" . "
  19.                 + "?gene rdfs:label ?geneLabel . }");
  20.         ResultSet results = qe.execSelect();
  21.         while (results.hasNext()) {
  22.             QuerySolution solution = results.next();
  23.             if (solution.contains("?geneLabel")) {
  24.                 System.out.println(solution.getLiteral("?geneLabel"));
  25.             }
  26.         }
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement