Jena Interface¶
The Jena interface is found by getting hold of a SessionConnection. This can be done with a database session, or with a URI:
// The database is created with appropriate configuration
Database database = ...;
// create the connection factory
[[ConnectionFactory]] connectionFactory = new [[ConnectionFactory]]();
// get a session from the database
Session session = database.newSession();
// now create the connection
[[SessionConnection]] connection = (SessionConnection)connectionFactory.newConnection(session);
The cast is needed when creating the connection, since this method returns a "Connection" interface, but only SessionConnections can be converted to JenaConnections.
To do the same thing with a server URI:
// create the connection factory
[[ConnectionFactory]] factory = new [[ConnectionFactory]]();
// use a URI appropriate to the required server
URI hostUri = new URI("rmi://localhost/server1");
// establish a connection
[[SessionConnection]] connection = (SessionConnection)factory.newConnection(hostUri);
A JenaConnection is obtained from a SessionConnection with the method getJenaConnection():
[[JenaConnection]] jenaConnection = connection.getJenaConnection();
Jena Connection Methods¶
The following are the methods on the JenaConnection interface. All parameters labeled graphUri refer to URIs representing graphs on a Mulgara server.
The following create/connect methods return instance of Jena Graphs or Models. Once you have instances of these objects, they can be used in an Jena-based application.
connectModel(String graphUri) - Connect to RDF data stored in a Mulgara server as a Jena Model. Does not create the model.
Returns: a Jena Model.
createModel(String graphUri) - Connect to RDF data stored in a Mulgara server as a Jena Model, creating the model if it does not exist.
Returns: a Jena Model.
connectModel(String graphUri, boolean createIfDoesNotExist) - Connect to RDF data stored in a Mulgara server as a Jena Model. Only creates the model if it does not exist and the createIfDoesNotExist flag is set.
Returns: a Jena Model.
connectModel(URI graphUri, boolean createIfDoesNotExist) - Connect to RDF data stored in a Mulgara server as a Jena Model. Only creates the model if it does not exist and the createIfDoesNotExist flag is set.
Returns: a Jena Model.
connectGraph(String graphUri) - Connect to RDF data stored in a Mulgara server as a Jena Graph. Does not create the graph.
Returns: a Jena Graph.
createGraph(String graphUri, boolean createIfDoesNotExist)) - Connect to RDF data stored in a Mulgara server as a Jena Graph. Only creates the graph if it does not exist and the createIfDoesNotExist flag is set.
Returns: a Jena Graph.
connectGraph(URI graphUri, boolean createIfDoesNotExist)) - Connect to RDF data stored in a Mulgara server as a Jena Graph. Only creates the graph if it does not exist and the createIfDoesNotExist flag is set.
Returns: a Jena Graph.
dropGraph(String graphUri) - Removes the graph from the Mulgara server.
dropGraph(URI graphUri) - Removes the graph from the Mulgara server.
Updated by Paula Gearon over 16 years ago ยท 2 revisions