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.
The Virtuoso Jena RDF Data Provider is a fully operational Native Graph Model Storage Provider for the Jena Framework, which enables Semantic Web applications written using the Jena RDF Frameworks to directly query the Virtuoso RDF Quad Store.
Providers are available for the latest Jena 2.6.x - 2.13.x and 3.0.x versions.
virt_jena.jar
) can be verified thus:
$ java -jar virt_jena3.jar OpenLink Virtuoso(TM) Provider for Jena(TM) Version 3.0.0 [Build 1.25] $ java -jar ./virt_jena2.jar OpenLink Virtuoso(TM) Provider for Jena(TM) Version 2.10.1 [Build 1.10] $ java -jar ./virt_jena.jar OpenLink Virtuoso(TM) Provider for Jena(TM) Version 2.6.2 [Build 1.10]
virtjdbc3.jar
), so don't replace if prompted during extraction.
Instead, rename the file extracted from the zip, and compare their versions to be sure you keep only the most recent.
$ java -cp ./virtjdbc3.jar virtuoso.jdbc3.Driver OpenLink Virtuoso(TM) Driver for JDBC(TM) Version 3.x [Build 3.62] $ java -cp ./virtjdbc3.fromzip.jar virtuoso.jdbc3.Driver OpenLink Virtuoso(TM) Driver for JDBC(TM) Version 3.x [Build 3.11]
VirtuosoSPARQLExampleX.java
, where X = {1,2,3,4,5,6,7,8,9,13,14}
.
Set the JDBC connection strings therein to point to a valid Virtuoso Server instance, using the form:
"jdbc:virtuoso://<virtuoso-hostname-or-IP-address>[:<data port>]/charset=UTF-8/log_enable=2", "<username>", "<password>"
"jdbc:virtuoso://localhost:1111/charset=UTF-8/log_enable=2", "dba", "dba"
charset=UTF-8
to ensure compatibility with non-Western codepages or character sets such as Cyrillic log_enable=2
to turn on row-level autocommit, important when processing large RDF data sets CLASSPATH
includes full paths to all of the following files Testing
section next virt_jenaX.jar
- Virtuoso Jena Provider for the required version virtjdbcX.jar
- Virtuoso JDBC Driver for the required version
javac VirtuosoSPARQLExample*.java
Once the Provider classes and sample program have been successfully compiled, the Provider can be tested using the included sample programs.
Ensure your active CLASSPATH
includes the full path to the directory containing the compiled VirtuosoSPARQLExample?*.class
files, as well as to each of the following files depending on Jena version in use --
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
jena-arq-2.9.4.jar
jena-iri-0.9.4.jar
jena-core-2.7.4.jar
jcl-over-slf4j-1.6.4.jar
log4j-1.2.16.jarslf4j-api-1.6.4.jar
slf4j-log4j12-1.6.4.jar
xercesImpl-2.10.0.jar
xml-apis-1.4.01.jar
commons-lang3-3.4.jar
virtjdbc4.jar
virt_jena2.jar
junit-4.5.jar
jena-arq-2.10.1.jar
jena-iri-0.9.6.jar
jena-core-2.10.1.jar
jena-core-2.10.1-tests.jar
jcl-over-slf4j-1.6.4.jar
log4j-1.2.16.jar
slf4j-api-1.6.4.jar
slf4j-log4j12-1.6.4.jar
xercesImpl-2.11.0.jar
xml-apis-1.4.01.jar
virtjdbc4.jar
virt_jena2.jar
junit-4.5.jar
commons-lang3-3.3.2.jar
jena-arq-3.0.0.jar
jena-iri-3.0.0.jar
jena-base-3.0.0.jar
jena-core-3.0.0.jar
jena-core-3.0.0-tests.jar
jcl-over-slf4j-1.7.12.jar
log4j-1.2.17.jar
slf4j-api-1.7.12.jar
slf4j-log4j12-1.7.12.jar
xercesImpl-2.11.0.jar
xml-apis-1.4.01.jar
jena-shaded-guava-3.0.0.jar
virtjdbc4.jar
virt_jena3.jar
If you've extracted the zips into the same directory where you compiled the example files, a command like this should do the job --
export CLASSPATH=`pwd`:`pwd`/*.jar:$CLASSPATH
java VirtuosoSPARQLExample1
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
java VirtuosoSPARQLExample2
java VirtuosoSPARQLExample3
graph.contains
method for searching triples, with the following command:
java VirtuosoSPARQLExample4
graph.find
method for searching triples, with the following command:
java VirtuosoSPARQLExample5
graph.getTransactionHandler
method, with the following command:
java VirtuosoSPARQLExample6
graph.getBulkUpdateHandler
method, with the following command:
java VirtuosoSPARQLExample7
java VirtuosoSPARQLExample8
CONSTRUCT
, DESCRIBE
, and ASK
SPARQL query forms, with the following command:
java VirtuosoSPARQLExample9
java VirtuosoSPARQLExample13
java VirtuosoSPARQLExample14
Javadocs covers the complete set of classes, interfaces, and methods implemented by the provider:
To use Virtuoso-specific SPARQL extensions (such as bif:contains
), queries must bypass the Jena/ARQ parser and go straight to the Virtuoso server.
This is done by using the VirtuosoQueryExecutionFactory.create()
method, instead of and without the Jena-specific QueryFactory.create()
method, which always invokes the Jena/ARQ parser, which in turn rejects any Virtuoso-specific extensions.
Thus one would execute a query as follows to bypass the Jena parser --
VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (query, set); vqe.execSelect();
-- rather than --
Query sparql = QueryFactory.create(query); VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (sparql, set); vqe.execSelect();
CategoryRDF CategoryOpenSource CategoryVirtuoso CategoryVOS CategoryJena? CategoryDocumentation