Not logged in : Login
(Sponging disallowed)

About: VirtJenaSPARQLExample9     Goto   Sponge   NotDistinct   Permalink

An Entity of Type : atom:Entry, within Data Space : www.openlinksw.com associated with source document(s)
QRcode icon
http://www.openlinksw.com/describe/?url=http%3A%2F%2Fwww.openlinksw.com%2Fdataspace%2Fdav%2Fwiki%2FVOS%2FVirtJenaSPARQLExample9

AttributesValues
has container
Date Created
maker
topic
described by
seeAlso
Date Modified
link
id
  • 4d4710cb8c991aeb9c9d4ca6260a917e
content
  • %META:TOPICPARENT{name="VirtJenaProvider"}% %VOSWARNING% ---+ Virtuoso Jena Provider - SPARQL Example 9 <verbatim> import com.hp.hpl.jena.query.*; import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.graph.Triple; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Graph; import com.hp.hpl.jena.rdf.model.*; import java.util.Iterator; import virtuoso.jena.driver.*; public class VirtuosoSPARQLExample9 { /** * Executes a SPARQL query against a virtuoso url and prints results. */ public static void main(String[] args) { String url; if(args.length == 0) url = "jdbc:virtuoso://localhost:1111"; else url = args[0]; /* STEP 1 */ VirtGraph set = new VirtGraph (url, "dba", "dba"); /* STEP 2 */ String str = "CLEAR GRAPH <http://test1>"; VirtuosoUpdateRequest vur = VirtuosoUpdateFactory.create(str, set); vur.exec(); str = "INSERT INTO GRAPH <http://test1> { <http://aa> <http://bb> 'cc' . <http://aa1> <http://bb> 123. }"; vur = VirtuosoUpdateFactory.create(str, set); vur.exec(); /* Select all data in virtuoso */ Query sparql = QueryFactory.create("SELECT * FROM <http://test1> WHERE { ?s ?p ?o }"); VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (sparql, set); ResultSet results = vqe.execSelect(); System.out.println("\nSELECT results:"); while (results.hasNext()) { QuerySolution rs = results.nextSolution(); RDFNode s = rs.get("s"); RDFNode p = rs.get("p"); RDFNode o = rs.get("o"); System.out.println(" { " + s + " " + p + " " + o + " . }"); } sparql = QueryFactory.create("DESCRIBE <http://aa> FROM <http://test1>"); vqe = VirtuosoQueryExecutionFactory.create (sparql, set); Model model = vqe.execDescribe(); Graph g = model.getGraph(); System.out.println("\nDESCRIBE results:"); for (Iterator i = g.find(Node.ANY, Node.ANY, Node.ANY); i.hasNext();) { Triple t = (Triple)i.next(); System.out.println(" { " + t.getSubject() + " " + t.getPredicate() + " " + t.getObject() + " . }"); } sparql = QueryFactory.create("CONSTRUCT { ?x <http://test> ?y } FROM <http://test1> WHERE { ?x <http://bb> ?y }"); vqe = VirtuosoQueryExecutionFactory.create (sparql, set); model = vqe.execConstruct(); g = model.getGraph(); System.out.println("\nCONSTRUCT results:"); for (Iterator i = g.find(Node.ANY, Node.ANY, Node.ANY); i.hasNext();) { Triple t = (Triple)i.next(); System.out.println(" { " + t.getSubject() + " " + t.getPredicate() + " " + t.getObject() + " . }"); } sparql = QueryFactory.create("ASK FROM <http://test1> WHERE { <http://aa> <http://bb> ?y }"); vqe = VirtuosoQueryExecutionFactory.create (sparql, set); boolean res = vqe.execAsk(); System.out.println("\nASK results: "+res); } } </verbatim>
Title
  • VirtJenaSPARQLExample9
has creator
is described using
atom:source
atom:updated
  • 2014-04-29T00:31:51Z
atom:title
  • VirtJenaSPARQLExample9
atom:author
label
  • VirtJenaSPARQLExample9
topic
atom:published
  • 2010-02-01T13:20:14Z
type
is topic of
is interest of
is made of
Faceted Search & Find service v1.17_git122 as of Jan 03 2023


Alternative Linked Data Documents: iSPARQL | ODE     Content Formats:   [cxml] [csv]     RDF   [text] [turtle] [ld+json] [rdf+json] [rdf+xml]     ODATA   [atom+xml] [odata+json]     Microdata   [microdata+json] [html]    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 08.03.3330 as of Apr 5 2024, on Linux (x86_64-generic-linux-glibc25), Single-Server Edition (30 GB total memory, 26 GB memory in use)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2024 OpenLink Software