Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.hp.hpl.jena.db
Class ModelRDB

    java.lang.Object
      com.hp.hpl.jena.enhanced.Polymorphic
          com.hp.hpl.jena.enhanced.EnhGraph
              com.hp.hpl.jena.rdf.model.impl.ModelCom
                  com.hp.hpl.jena.db.ModelRDB

All Implemented Interfaces:
  Model, ModelCon, ModelGraphInterface, ModelLock, RDFReaderF, RDFWriterF, Lock, PrefixMapping

    public class ModelRDB

extends com.hp.hpl.jena.rdf.model.impl.ModelCom
implements Model

A persistent relational database implemention of the RDF API.

This implementation of the RDF API stores all its data in a relational database.

To construct a persistent RDB Model, first load the jdbc connector for your database - in this example, mysql:

`Class.forName("com.mysql.jdbc.Driver");`

Then create a connection to the database:

`IDBConnection conn = new DBConnection("jdbc:mysql://localhost/test", "test", "", "MySQL");`

Now, using that connection, you can construct Models in the database:

`Model m = ModelRDB.createModel(conn);`

Version:
  $Revision: 1.22 $
Author:
  csayers (based on ModelMem written by bwm and the Jena 1 version of Model RDB by der.)

Nested Class Summary

Nested classes/interfaces inherited from interface com.hp.hpl.jena.shared.PrefixMapping
`PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException`

Field Summary

Fields inherited from interface com.hp.hpl.jena.shared.PrefixMapping
`Extended, Standard`

Fields inherited from interface com.hp.hpl.jena.rdf.model.ModelLock
`READ, WRITE`

Constructor Summary
`ModelRDB(GraphPersonality p, GraphRDB graph)` A model which is stored persistently in a Relational DataBase Most applications should not call the constructor - use ModelRDB.createModel (to create a new model) or ModelRDB.open (to open an exising model).
`ModelRDB(GraphRDB graph)`
`ModelRDB(IDBConnection dbcon)` Deprecated. Since Jena 2.0, this call is not recommended - in the short-term use ModelRDB.open or ModelRDB.createModel; in the longer-term use factory methods to construct persistent models.
`ModelRDB(IDBConnection dbcon, java.lang.String modelID)` Deprecated. Since Jena 2.0, this call is not recommended - in the short-term use ModelRDB.open or ModelRDB.createModel; in the longer-term use factory methods to construct persistent models.

Method Summary
`void` | `clear()` Deprecated. Since Jena 2.0 this call is not recommended (it's name is misleading) - to clear an entire database use DBConnection.cleanDB, to remove just this Model use Model.remove().
`void` | `close()` Close the Model and free up resources held.
`static ModelRDB` | `create(IDBConnection dbcon, java.lang.String databaseType)` Deprecated. Since Jena 2.0 this call is no longer needed - it is preferable to specify the database type when constructing the DBConnection. Then use the call ModelRDB.createModel(IDBConnection)
`static ModelRDB` | `create(IDBConnection dbcon, java.lang.String layoutType, java.lang.String databaseType)` Deprecated. Since Jena 2.0 this call is no longer needed - it is preferable to specify the database type when constructing the DBConnection and to modify the layout by using the properties in the DBConnection. Then use the call ModelRDB.createModel(IDBConnection)
`static ModelRDB` | `createModel(IDBConnection dbcon)` Create a new default model on an existing database.
`static ModelRDB` | `createModel(IDBConnection dbcon, Model modelProperties)` Create a new model on an existing database.
`static ModelRDB` | `createModel(IDBConnection dbcon, java.lang.String name)` Create a new model on an existing database.
`static ModelRDB` | `createModel(IDBConnection dbcon, java.lang.String name, Model modelProperties)` Create a new model on an existing database.
`static void` | `deleteModel(IDBConnection dbcon, java.lang.String name)` Deprecated. Since Jena 2.0, to remove a model use the ModelRDB.remove()
`IDBConnection` | `getConnection()` A convenience function to return the connection
`static Model` | `getDefaultModelProperties(IDBConnection dbcon)` Retrieve a default set of model customization properties The returned default set of properties is suitable for use in a call to ModelRDB.create(..., modelProperties);
`boolean` | `getDoDuplicateCheck()` Get the value of DoDuplicateCheck
`boolean` | `getDoFastpath()` Get the value of DoFastpath.
`Model` | `getModelProperties()` Returns a Jena Model containing model-specific properties.
`boolean` | `getQueryFullReified()` Get the value of QueryFullReified.
`boolean` | `getQueryOnlyAsserted()` Get the value of QueryOnlyAsserted.
`boolean` | `getQueryOnlyReified()` Get the value of QueryOnlyReified.
`static ExtendedIterator` | `listModels(IDBConnection dbcon)` List the names of all models stored in the database
`Model` | `loadAll()` Deprecated. Since Jena 2.0, this call is not recommended. Instead use the soon-to-be-released bulk-load functions.
`static ModelRDB` | `open(IDBConnection dbcon)` Open the default model from an existing rdf database.
`static ModelRDB` | `open(IDBConnection dbcon, java.lang.String name)` Open an existing rdf database.
`void` | `remove()` Remove all traces of this particular Model from the database.
`void` | `setDoDuplicateCheck(boolean bool)` Set the value of DoDuplicateCheck.
`void` | `setDoFastpath(boolean val)` Set the value of DoFastpath.
`void` | `setDoImplicitJoin(boolean val)` Set the value of DoImplicitJoin.
`void` | `setQueryFullReified(boolean opt)` Set the value of QueryFullReified.
`void` | `setQueryOnlyAsserted(boolean opt)` Set the value of QueryOnlyAsserted.
`void` | `setQueryOnlyReified(boolean opt)` Set the value of QueryOnlyReified.

Methods inherited from class com.hp.hpl.jena.rdf.model.impl.ModelCom
`abort, adapt, add, add, add, add, add, add, add, add, add, add, add, add, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addNamespaces, addTyped, asFilter, asModel, asNode, asRDFNode, asStatement, asStatements, asStatements, asStatements, begin, commit, contains, contains, contains, contains, contains, containsAll, containsAll, containsAny, containsAny, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsResource, containsTyped, createAlt, createAlt, createBag, createBag, createList, createList, createList, createLiteral, createLiteral, createLiteral, createLiteral, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createProperty, createProperty, createReifiedStatement, createReifiedStatement, createResource, createResource, createResource, createResource, createResource, createResource, createResource, createSeq, createSeq, createStatement, createStatement, createStatement, createStatement, createStatement, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, difference, enterCriticalSection, executeInTransaction, expandPrefix, findTriplesFrom, getAlt, getAlt, getAnyReifiedStatement, getBag, getBag, getDefaultModelPrefixes, getGraph, getHiddenStatements, getLock, getModelLock, getNsPrefixMap, getNsPrefixURI, getNsURIPrefix, getProperty, getProperty, getProperty, getRDFNode, getReader, getReader, getReificationStyle, getRequiredProperty, getResource, getResource, getSeq, getSeq, getWriter, getWriter, independent, intersect, intersection, isClosed, isEmpty, isIsomorphicWith, isReified, leaveCriticalSection, listBySubject, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listlLiteralStatements, listNameSpaces, listObjects, listObjectsOfProperty, listObjectsOfProperty, listReifiedStatements, listReifiedStatements, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listStatements, listStatements, listStatements, listStatements, listStatements, listSubjects, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, lock, notifyEvent, qnameFor, query, queryHandler, read, read, read, read, read, read, read, register, reifiedToString, remove, remove, remove, remove, remove, remove, remove, removeAll, removeAll, removeAllReifications, removeNsPrefix, removeReification, samePrefixMappingAs, setDefaultModelPrefixes, setNsPrefix, setNsPrefixes, setNsPrefixes, setReaderClassName, setWriterClassName, shortForm, size, supportsSetOperations, supportsTransactions, toString, union, unregister, withDefaultMappings, write, write, write, write, write, write`

Methods inherited from class com.hp.hpl.jena.enhanced.EnhGraph
`asGraph, equals, getNodeAs, getNodeCacheControl, hashCode, isIsomorphicWith, isValid, setNodeCache`

Methods inherited from class com.hp.hpl.jena.enhanced.Polymorphic
`addView, supports`

Methods inherited from class java.lang.Object
`equals, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.hp.hpl.jena.rdf.model.Model
`abort, add, add, add, add, add, add, begin, commit, contains, contains, contains, containsAll, containsAll, containsAny, containsAny, containsResource, createList, createList, createList, createLiteral, createLiteral, createProperty, createReifiedStatement, createReifiedStatement, createResource, createResource, createResource, createStatement, createTypedLiteral, createTypedLiteral, createTypedLiteral, difference, equals, executeInTransaction, getAnyReifiedStatement, getLock, getProperty, getProperty, getReificationStyle, getRequiredProperty, getResource, independent, intersection, isClosed, isEmpty, isIsomorphicWith, isReified, listNameSpaces, listObjects, listObjectsOfProperty, listObjectsOfProperty, listReifiedStatements, listReifiedStatements, listResourcesWithProperty, listResourcesWithProperty, listStatements, listStatements, listStatements, listSubjects, listSubjectsWithProperty, listSubjectsWithProperty, notifyEvent, query, read, read, read, read, read, read, read, register, remove, remove, remove, removeAll, removeAll, removeAllReifications, removeReification, size, supportsSetOperations, supportsTransactions, union, unregister, write, write, write, write, write, write`

Methods inherited from interface com.hp.hpl.jena.rdf.model.ModelCon
`add, add, add, add, add, add, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, contains, contains, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, createAlt, createAlt, createBag, createBag, createLiteral, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createProperty, createResource, createResource, createResource, createResource, createSeq, createSeq, createStatement, createStatement, createStatement, createStatement, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, getAlt, getAlt, getBag, getBag, getProperty, getRDFNode, getResource, getSeq, getSeq, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listlLiteralStatements, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listStatements, listStatements, listSubjectsWithProperty, listSubjectsWithProperty, remove, remove, remove, remove`

Methods inherited from interface com.hp.hpl.jena.rdf.model.ModelGraphInterface
`asRDFNode, asStatement, getGraph, queryHandler`

Methods inherited from interface com.hp.hpl.jena.rdf.model.RDFReaderF
`getReader, getReader, setReaderClassName`

Methods inherited from interface com.hp.hpl.jena.rdf.model.RDFWriterF
`getWriter, getWriter, setWriterClassName`

Methods inherited from interface com.hp.hpl.jena.shared.PrefixMapping
`expandPrefix, getNsPrefixMap, getNsPrefixURI, getNsURIPrefix, lock, qnameFor, removeNsPrefix, samePrefixMappingAs, setNsPrefix, setNsPrefixes, setNsPrefixes, shortForm, withDefaultMappings`

Methods inherited from interface com.hp.hpl.jena.shared.Lock
`enterCriticalSection, leaveCriticalSection`

Constructor Detail

### ModelRDB

    public ModelRDB(IDBConnection dbcon)
             throws RDFRDBException

  Deprecated. Since Jena 2.0, this call is not recommended - in the short-term use ModelRDB.open or ModelRDB.createModel; in the longer-term use factory methods to construct persistent models.

  Construct a model which is stored persistently in a Relational DataBase If a model already exists in the database, then it is opened, otherwise a new model with default name and formatting is inserted and opened.

  Parameters:
    `dbcon` - a Connection specifying the database connection
  Throws:
    `RDFRDBException`

### ModelRDB

    public ModelRDB(IDBConnection dbcon,
                    java.lang.String modelID)
             throws RDFRDBException

  Deprecated. Since Jena 2.0, this call is not recommended - in the short-term use ModelRDB.open or ModelRDB.createModel; in the longer-term use factory methods to construct persistent models.

  Construct a model which is stored persistently in a Relational DataBase If a model with the specified identifier already exists in the database, then it is opened, otherwise a new model with default formatting is inserted and opened.

  Parameters:
    `dbcon` - a Connection specifying the database connection
    `modelID` - is the identifier of an RDF model within the database. The modelID "DEFAULT" is reserved and may not be used for user models.
  Throws:
    `RDFRDBException`

### ModelRDB

    public ModelRDB(GraphPersonality p,
                    GraphRDB graph)
             throws RDFRDBException

  A model which is stored persistently in a Relational DataBase Most applications should not call the constructor - use ModelRDB.createModel (to create a new model) or ModelRDB.open (to open an exising model).

  Parameters:
    `p` - the GraphPersonality of the resulting Model
    `graph` - a GraphRDB to be exposed through the model interface
  Throws:
    `RDFRDBException`
  Since:
    Jena 2.0

### ModelRDB

    public ModelRDB(GraphRDB graph)

Method Detail

### open

    public static ModelRDB open(IDBConnection dbcon)
                         throws RDFRDBException

  Open the default model from an existing rdf database. The layout and datatype type information will be dynamically loaded from the database.

  Parameters:
    `dbcon` - an IDBConnection specifying the database connection
  Throws:
    `RDFRDBException`

### open

    public static ModelRDB open(IDBConnection dbcon,
                                java.lang.String name)
                         throws RDFRDBException

  Open an existing rdf database. The layout and datatype type information will be dynamically loaded from the database. Will throw an RDFDBException if the database does not seem to formated.

  Parameters:
    `dbcon` - a IDBConnection specifying the database connection
    `name` - the name of the RDF model to open
  Throws:
    `RDFRDBException`

### createModel

    public static ModelRDB createModel(IDBConnection dbcon)
                                throws RDFRDBException

  Create a new default model on an existing database. Will format the database if it has not already been formatted.

  Parameters:
    `dbcon` - a DBConnection specifying the database connection
  Throws:
    `RDFRDBException`
  Since:
    Jena 2.0

### createModel

    public static ModelRDB createModel(IDBConnection dbcon,
                                       Model modelProperties)
                                throws RDFRDBException

  Create a new model on an existing database. Will format the database if it has not already been formatted.

  Use the properties to optionally customize the model - this won't change the results you see when using the model interface, but it may alter the speed with which you get them or the space required by the underlying database.

  The properties must form a complete and consistent set. The easist way to get a complete and consistent set is to call getDefaultModelProperties, modify it, and then use that as an argument in the call.

  Parameters:
    `dbcon` - a DBConnection specifying the database connection
    `modelProperties` - a Model containing customization properties
  Throws:
    `RDFRDBException`
  Since:
    Jena 2.0

### createModel

    public static ModelRDB createModel(IDBConnection dbcon,
                                       java.lang.String name)
                                throws RDFRDBException

  Create a new model on an existing database. Will format the database if it has not already been formatted.

  Parameters:
    `dbcon` - a DBConnectionI specifying the database connection
    `name` - the name to give the newly created model. The name "DEFAULT" is reserved and may not be used for user models.
  Throws:
    `RDFRDBException`

### createModel

    public static ModelRDB createModel(IDBConnection dbcon,
                                       java.lang.String name,
                                       Model modelProperties)
                                throws RDFRDBException

  Create a new model on an existing database. Will format the database if it has not already been formatted.

  Use the properties to optionally customize the model - this won't change the results you see when using the model interface, but it may alter the speed with which you get them or the space required by the underlying database.

  The properties must form a complete and consistent set. The easist way to get a complete and consistent set is to call getDefaultModelProperties, modify it, and then use that as an argument in the call.

  Parameters:
    `dbcon` - a DBConnection specifying the database connection
    `name` - the name to give the newly created model. The name "DEFAULT" is reserved and may not be used for user models.
    `modelProperties` - a Model containing customization properties
  Throws:
    `RDFRDBException`
  Since:
    Jena 2.0

### create

    public static ModelRDB create(IDBConnection dbcon,
                                  java.lang.String layoutType,
                                  java.lang.String databaseType)
                           throws RDFRDBException

  Deprecated. Since Jena 2.0 this call is no longer needed - it is preferable to specify the database type when constructing the DBConnection and to modify the layout by using the properties in the DBConnection. Then use the call ModelRDB.createModel(IDBConnection)

  Create a new database suitable for storing RDF data. In fact the database has to exist since jdbc can't create an empty database from a vacuum but it can be empty and this call will format it with appropriate tables and stored procedures.

  The appropriate RDF-RDB driver to use is assumed to be the class Driver. If that can't be found it defaults to looking for a property file in /etc/Driver.config and uses that to determine the driver class and parameters.

  Parameters:
    `dbcon` - a DBConnection specifying the database connection
    `layoutType` - the name of the layout style to use. Currently one of: "Generic", "Hash", "MMGeneric", "MMHash", "Proc", "ThinProc".
    `databaseType` - the name of the database type. Currently one of: "Interbase" "Postgresql" "Mysql" "Oracle". This may seem a little redundant given that the jdbc uri implicitly contains this information but there is no standard way of extracting this (esp. if the user connects via a bridge).
  Throws:
    `RDFRDBException`

### create

    public static ModelRDB create(IDBConnection dbcon,
                                  java.lang.String databaseType)
                           throws RDFRDBException

  Deprecated. Since Jena 2.0 this call is no longer needed - it is preferable to specify the database type when constructing the DBConnection. Then use the call ModelRDB.createModel(IDBConnection)

  Create a new database suitable for storing RDF data. In fact the database has to exist since jdbc can't create an empty database from a vacuum but it can be empty and this call will format it with appropriate tables and stored procedures.

  Uses a default layout format which is able to support multiple models in a single database.

  Parameters:
    `dbcon` - a DBConnectionI specifying the database connection
    `databaseType` - the name of the database type. Currently one of: "Interbase" "Postgresql" "Mysql" "Oracle". This may seem a little redundant given that the jdbc uri implicitly contains this information but there is no standard way of extracting this (esp. if the user connects via a bridge).
  Throws:
    `RDFRDBException`

### getModelProperties

    public Model getModelProperties()

  Returns a Jena Model containing model-specific properties. These describe the optimization/layout for this model in the database. The returned Model is a copy, modifying it will have no immediate effect on the database.

  Since:
    Jena 2.0

### getDefaultModelProperties

    public static Model getDefaultModelProperties(IDBConnection dbcon)

  Retrieve a default set of model customization properties The returned default set of properties is suitable for use in a call to ModelRDB.create(..., modelProperties);

  Parameters:
    `dbcon` - a DBConnectionI specifying the database connection
  Returns:
    Model containing default properties

### listModels

    public static ExtendedIterator listModels(IDBConnection dbcon)
                                       throws RDFRDBException

  List the names of all models stored in the database

  Returns:
    ExtendedIterator over the model names.
  Throws:
    `RDFRDBException`

### close

    public void close()

  Close the Model and free up resources held.

  Not all implementations of Model require this method to be called. But some do, so in general its best to call it when done with the object, rather than leave it to the finalizer.

  Specified by:
    `close` in interface `Model`
  Overrides:
    `close` in class `com.hp.hpl.jena.rdf.model.impl.ModelCom`

### remove

    public void remove()
                throws RDFRDBException

  Remove all traces of this particular Model from the database.

  Throws:
    `RDFRDBException`

### getConnection

    public IDBConnection getConnection()

  A convenience function to return the connection

### clear

    public void clear()
               throws RDFRDBException

  Deprecated. Since Jena 2.0 this call is not recommended (it's name is misleading) - to clear an entire database use DBConnection.cleanDB, to remove just this Model use Model.remove().

  Remove all the statements from the database which are associated with just this model. This no longer reformats the database (which makes it safer and useful for multi-model databases) but means that it is not guaranteed to garbage collect the resource table.

  Throws:
    `RDFRDBException`

### deleteModel

    public static void deleteModel(IDBConnection dbcon,
                                   java.lang.String name)
                            throws RDFRDBException

  Deprecated. Since Jena 2.0, to remove a model use the ModelRDB.remove()

  Remove a named model from an existing multi-model database. Will throw an RDFDBException if the database layout does not support multiple models or if the database does not seem to formated.

  Parameters:
    `dbcon` - a DBConnectionI specifying the database connection
    `name` - the name to give the newly created model
  Throws:
    `RDFRDBException`

### loadAll

    public Model loadAll()

  Deprecated. Since Jena 2.0, this call is not recommended. Instead use the soon-to-be-released bulk-load functions.

  Loads all the statements for this model into an in-memory model.

  Returns:
    a ModelMem containing the whole of the RDB model

### getDoDuplicateCheck

    public boolean getDoDuplicateCheck()

  Get the value of DoDuplicateCheck

  Returns:
    bool boolean

### setDoDuplicateCheck

    public void setDoDuplicateCheck(boolean bool)

  Set the value of DoDuplicateCheck.

  Parameters:
    `bool` - boolean

### setDoFastpath

    public void setDoFastpath(boolean val)

  Set the value of DoFastpath.

  Parameters:
    `val` - boolean

### getDoFastpath

    public boolean getDoFastpath()

  Get the value of DoFastpath.

  Returns:
    boolean

### setQueryOnlyAsserted

    public void setQueryOnlyAsserted(boolean opt)

  Set the value of QueryOnlyAsserted.

  Parameters:
    `opt` - boolean

### getQueryOnlyAsserted

    public boolean getQueryOnlyAsserted()

  Get the value of QueryOnlyAsserted.

  Returns:
    boolean

### setQueryOnlyReified

    public void setQueryOnlyReified(boolean opt)

  Set the value of QueryOnlyReified.

  Parameters:
    `opt` - boolean

### getQueryOnlyReified

    public boolean getQueryOnlyReified()

  Get the value of QueryOnlyReified.

  Returns:
    boolean

### setQueryFullReified

    public void setQueryFullReified(boolean opt)

  Set the value of QueryFullReified.

  Parameters:
    `opt` - boolean

### getQueryFullReified

    public boolean getQueryFullReified()

  Get the value of QueryFullReified.

  Returns:
    boolean

### setDoImplicitJoin

    public void setDoImplicitJoin(boolean val)

  Set the value of DoImplicitJoin.

  Parameters:
    `val` - boolean

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP