Attributes | Values |
---|
type
| |
Date Created
| |
Date Modified
| |
label
| - VirtJenaSPARQLExample2
- VirtJenaSPARQLExample2
|
seeAlso
| |
maker
| |
Title
| - VirtJenaSPARQLExample2
- VirtJenaSPARQLExample2
|
isDescribedUsing
| |
has creator
| |
content
| - %META:TOPICPARENT{name="VirtJenaProvider"}%
%VOSWARNING%
---+ Virtuoso Jena Provider - SPARQL Example 2
<verbatim>
import com.hp.hpl.jena.query.*;
import com.hp.hpl.jena.rdf.model.RDFNode;
import virtuoso.jena.driver.*;
public class VirtuosoSPARQLExample2 {
/**
* 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 graph = new VirtGraph ("Example2", url, "dba", "dba");
/* STEP 2 */
/* Load data to Virtuoso */
graph.clear ();
System.out.print ("Begin read from 'http://www.w3.org/People/Berners-Lee/card#i' ");
graph.read("http://www.w3.org/People/Berners-Lee/card#i", "RDF/XML");
System.out.println ("\t\t\t Done.");
System.out.print ("Begin read from 'http://demo.openlinksw.com/dataspace/person/demo#this' ");
graph.read("http://demo.openlinksw.com/dataspace/person/demo#this", "RDF/XML");
System.out.println ("\t Done.");
System.out.print ("Begin read from 'http://kidehen.idehen.net/dataspace/person/kidehen#this' ");
graph.read("http://kidehen.idehen.net/dataspace/person/kidehen#this", "RDF/XML");
System.out.println ("\t Done.");
/* STEP 3 */
/* Select only from VirtGraph */
Query sparql = QueryFactory.create("SELECT ?s ?p ?o WHERE { ?s ?p ?o }");
/* STEP 4 */
VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (sparql, graph);
ResultSet results = vqe.execSelect();
while (results.hasNext()) {
QuerySolution result = results.nextSolution();
RDFNode graph_name = result.get("graph");
RDFNode s = result.get("s");
RDFNode p = result.get("p");
RDFNode o = result.get("o");
System.out.println(graph_name + " { " + s + " " + p + " " + o + " . }");
}
System.out.println("graph.getCount() = " + graph.getCount());
}
}
</verbatim>
- %META:TOPICPARENT{name="VirtJenaProvider"}%
%VOSWARNING%
---+ Virtuoso Jena Provider - SPARQL Example 2
<verbatim>
import com.hp.hpl.jena.query.*;
import com.hp.hpl.jena.rdf.model.RDFNode;
import virtuoso.jena.driver.*;
public class VirtuosoSPARQLExample2 {
/**
* 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 graph = new VirtGraph ("Example2", url, "dba", "dba");
/* STEP 2 */
/* Load data to Virtuoso */
graph.clear ();
System.out.print ("Begin read from 'http://www.w3.org/People/Berners-Lee/card#i' ");
graph.read("http://www.w3.org/People/Berners-Lee/card#i", "RDF/XML");
System.out.println ("\t\t\t Done.");
System.out.print ("Begin read from 'http://demo.openlinksw.com/dataspace/person/demo#this' ");
graph.read("http://demo.openlinksw.com/dataspace/person/demo#this", "RDF/XML");
System.out.println ("\t Done.");
System.out.print ("Begin read from 'http://kidehen.idehen.net/dataspace/person/kidehen#this' ");
graph.read("http://kidehen.idehen.net/dataspace/person/kidehen#this", "RDF/XML");
System.out.println ("\t Done.");
/* STEP 3 */
/* Select only from VirtGraph */
Query sparql = QueryFactory.create("SELECT ?s ?p ?o WHERE { ?s ?p ?o }");
/* STEP 4 */
VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (sparql, graph);
ResultSet results = vqe.execSelect();
while (results.hasNext()) {
QuerySolution result = results.nextSolution();
RDFNode graph_name = result.get("graph");
RDFNode s = result.get("s");
RDFNode p = result.get("p");
RDFNode o = result.get("o");
System.out.println(graph_name + " { " + s + " " + p + " " + o + " . }");
}
System.out.println("graph.getCount() = " + graph.getCount());
}
}
</verbatim>
|
id
| - 2852f31c14aaf3f48b0d53a3f67d551d
- 2852f31c14aaf3f48b0d53a3f67d551d
|
link
| |
has container
| |
http://rdfs.org/si...ices#has_services
| |
atom:title
| - VirtJenaSPARQLExample2
- VirtJenaSPARQLExample2
|
atom:source
| |
atom:author
| |
atom:published
| - 2017-06-13T05:45:20Z
- 2017-06-13T05:45:20Z
|
atom:updated
| - 2017-06-13T05:45:20Z
- 2017-06-13T05:45:20Z
|
topic
| |
is made
of | |
is container of
of | |
is link
of | |
is http://rdfs.org/si...vices#services_of
of | |
is links to
of | |
is creator of
of | |
is atom:entry
of | |
is atom:contains
of | |