Virtuoso Jena Provider
What is Jena
Jena is an open source Semantic Web framework for Java. It provides an API to extract data from and write to RDF graphs. The graphs are represented as an abstract "model". A model can be sourced with data from files, databases, URIs or a combination of these. A Model can also be queried through SPARQL and updated through SPARUL.
What is the Virtuoso Jena Provider
The Virtuoso Jena RDF Data Provider is a fully operational Native Graph Model Storage Provider for the Jena Framework, enables Semantic Web applications written using the Jena RDF Frameworks to query the Virtuoso RDF Quad store directly. The Provider has been tested against the Jena 2.5.5 version currently available.
Setup
Required Files
- Virtuoso Jena Provider JAR file, virt_jena.jar
- Virtuoso JDBC Driver JAR file, virtjdbc3.jar
- Jena Framework and associated classes, jenajars.zip
- Sample programs, virtjenasamples.zip
Compiling Jena Sample Programs
- Edit the sample programs
VirtuosoSPARQLExampleX.java, whereX= 1 to 9. Set the JDBC connection strings within to point to a valid Virtuoso Server instance, using the form:
"jdbc:virtuoso://localhost:1111/charset=UTF-8/log_enable=2", "dba", "dba"
- charset=UTF-8: to work correctly with different encodings such as cirilic, etc.
- log_enable=2: to use row auto commit
- use these settings to process large rdf data.
- Ensure that full paths to
jena.jar,arq.jar,virt_jena.jar, andvirtjdbc3.jarare included in the activeCLASSPATH setting. - Compile the Jena Sample applications using the following command:
javac VirtuosoSPARQLExample1.java VirtuosoSPARQLExample2.java VirtuosoSPARQLExample3.java VirtuosoSPARQLExample4.java VirtuosoSPARQLExample5.java VirtuosoSPARQLExample6.java VirtuosoSPARQLExample7.java VirtuosoSPARQLExample8.java VirtuosoSPARQLExample9.java
Testing
Once the Provider classes and sample program have been successfully compiled, the Provider can be tested using the sample programs included.
Ensure your active CLASSPATH includes full paths to all of the following files, before executing the example commands --
-
icu4j_3_4.jar -
iri.jar -
xercesImpl.jar -
axis.jar -
commons-logging-1.1.1.jar -
jena.jar -
arq.jar -
virtjdbc3.jar -
virt_jena.jar
-
VirtuosoSPARQLExample1 returns the contents of the RDF Quad store of the targeted Virtuoso instance, with the following command:
java VirtuosoSPARQLExample1
-
VirtuosoSPARQLExample2 reads in the contents of the following FOAF URIs --
http://kidehen.idehen.net/dataspace/person/kidehen#this http://www.w3.org/People/Berners-Lee/card#i http://demo.openlinksw.com/dataspace/person/demo#this
-- and returns the RDF data stored, with the following command:
java VirtuosoSPARQLExample2
-
VirtuosoSPARQLExample3 performs simple addition and deletion operation on the content of the triple store, with the following command:
java VirtuosoSPARQLExample3
-
VirtuosoSPARQLExample4 demonstrates the use of the
graph.containsmethod for searching triples, with the following command:
java VirtuosoSPARQLExample4
-
VirtuosoSPARQLExample5 demonstrates the use of the
graph.findmethod for searching triples, with the following command:
java VirtuosoSPARQLExample5
-
VirtuosoSPARQLExample6 demonstrates the use of the
graph.getTransactionHandlermethod, with the following command:
java VirtuosoSPARQLExample6
-
VirtuosoSPARQLExample7 demonstrates the use of the
graph.getBulkUpdateHandlermethod, with the following command:
java VirtuosoSPARQLExample7
-
VirtuosoSPARQLExample8 demonstrates how to insert triples into a graph, with the following command:
java VirtuosoSPARQLExample8
-
VirtuosoSPARQLExample9 demonstrates the use of the
CONSTRUCT,DESCRIBE, andASKSPARQL query forms, with the following command:
java VirtuosoSPARQLExample9
Javadoc API Documentation
Jena Provider Javadoc API Documentation is available enabling the complete set of classes, interfaces and methods implemented for the provider to be viewed.