Chapter 3. Connect to NoSQL Database

Table of Contents

Making a single connection to an Oracle NoSQL Database
Connection Pooling

This section describes two ways the RDF Graph feature can connect to Oracle NoSQL Database. For comprehensive documentation of the API calls that support the connections, see the RDF Graph feature reference information (Javadoc).

Making a single connection to an Oracle NoSQL Database

The RDF Graph feature provides a convenient handler to manage connections and operations to the Oracle NoSQL Database. This handler represents a relevant component used by the OracleGraphNoSql and the DatasetGraphNoSql to access and persist all RDF data in the Oracle NoSQL Database.

A connection handler is provided through the RDF Graph feature OracleNoSQLConnection class. Once this class is initialized, you can use this connection object to load, modify, query, and remove RDF triple or quad data from the Oracle NoSQL Database through the Graph and DatasetGraph APIs.

The following example sets up an OracleNoSqlConnection object.

public static void main(String[] args) throws Exception
String szStoreName = args[0];
String szHostName  = args[1];
String szHostPort  = args[2];
String szModelName = args[3];
System.out.println("Creating connection handler");    
OracleNoSqlConnection conn 
                       = OracleNoSqlConnection.createInstance(szStoreName,
OracleModelNoSql model 
    = OracleModelNoSql.createOracleModelNoSql(szModelName,conn);
System.out.println("Clear model");
String queryString = "select ?x ?y ?z WHERE {?x ?y ?z}";
System.out.println("Execute query " + queryString);
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, model);
try {
      ResultSet results = qexec.execSelect();
      ResultSetFormatter.out(System.out, results, query);
finally {

// Close connection