8.1 Oracle RDF Graph Support for Eclipse RDF4J Overview

The Oracle RDF Graph Adapter for Eclipse RDF4J API provides a Java-based interface to Oracle RDF data through an API framework and tools that adhere to the Eclipse RDF4J SAIL API.

The RDF Graph support for Eclipse RDF4J is similar to the RDF Graph support for Apache Jena as described in RDF Graph Support for Apache Jena.

The adapter for Eclipse RDF4J provides a Java API for interacting with RDF data stored in Oracle Database. It also provides integration with the following Eclipse RDF4J tools:

  • Eclipse RDF4J Server, which provides an HTTP SPARQL endpoint.
  • Eclipse RDF4J Workbench, which is a web-based client UI for managing databases and executing queries.

The features provided by the adapter for Eclispe RDF4J include:

  • Loading (bulk and incremental), exporting, and removing statements, with and without context
  • Querying data, with and without context
  • Updating data, with and without context

Oracle RDF Graph Adapter for Eclipse RDF4J implements various interfaces of the Eclipse RDF4J Storage and Inference Layer (SAIL) API.

For example, the class OracleSailConnection is an Oracle implementation of the Eclipse RDF4J SailConnection interface, and the class OracleSailStore extends AbstractSail which is an Oracle implementation of the Eclipse RDF4J Sail interface.

The following example demonstrates a typical usage flow for the RDF Graph support for Eclipse RDF4J.

Example 8-1 Sample Usage flow for RDF Graph Support for Eclipse RDF4J Using a Schema-Private RDF Network

String networkOwner = "SCOTT";
String networkName = "NET1";
String modelName = "UsageFlow";
OraclePool oraclePool = new OraclePool(jdbcurl, user, password);
SailRepository sr = new SailRepository(new OracleSailStore(oraclePool, modelName, networkOwner, networkName));
SailRepositoryConnection conn = sr.getConnection();

//A ValueFactory factory for creating IRIs, blank nodes, literals and statements
ValueFactory vf = conn.getValueFactory();
IRI alice = vf.createIRI("http://example.org/Alice");
IRI friendOf = vf.createIRI("http://example.org/friendOf");
IRI bob = vf.createIRI("http://example.org/Bob");
Resource context1 = vf.createIRI("http://example.org/");

// Data loading can happen here.
conn.add(alice, friendOf, bob, context1);
String query =
  " PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
  " PREFIX dc: <http://purl.org/dc/elements/1.1/> " +
  " select ?s ?p ?o ?name WHERE {?s ?p ?o . OPTIONAL {?o foaf:name ?name .} } ";
TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
TupleQueryResult tqr = tq.evaluate();
while (tqr.hasNext()) {
    System.out.println((tqr.next().toString()));
}
tqr.close();
conn.close();
sr.shutDown();