com.hp.hpl.jena.db
Interface IDBConnection

All Known Implementing Classes:
DBConnection

public interface IDBConnection

Encapsulate the specification of a jdbc connection, mostly used to simplify the calling pattern for ModelRDB factory methods.

Version:
$Revision: 1.1 $ on $Date: 2009/06/29 08:55:52 $
Author:
csayers (based on earlier code by der)

Method Summary
 void cleanDB()
          Clear all RDF information from the database.
 void close()
          Close the jdbc connection
 boolean containsDefaultModel()
          Test if a default model is contained in the database.
 boolean containsModel(java.lang.String name)
          Test if a given model is contained in the database.
 com.hp.hpl.jena.util.iterator.ExtendedIterator<java.lang.String> getAllModelNames()
          Retrieve a list of all models in the database
 java.sql.Connection getConnection()
          Return the jdbc connection or null if we no longer have access to a connection.
 Model getDatabaseProperties()
          Returns a Jena Model containing database properties.
 java.lang.String getDatabaseType()
          Get the database type.
 Model getDefaultModelProperties()
          Retrieve a default set of model customization properties.
 com.hp.hpl.jena.db.impl.IRDBDriver getDriver()
          Get the database-specific driver For this to work, it needs to know the type of database being used.
 boolean isFormatOK()
          Return true if the database seems to be formated for RDF storage.
 void setDatabaseProperties(Model propertyModel)
          Sets database-specific properties.
 void setDatabaseType(java.lang.String databaseType)
          Set the database type manually.
 void setDriver(com.hp.hpl.jena.db.impl.IRDBDriver driver)
          Set the IRDBDriver to use for this connection.
 

Method Detail

getConnection

java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Return the jdbc connection or null if we no longer have access to a connection.

Throws:
java.sql.SQLException

close

void close()
           throws java.sql.SQLException
Close the jdbc connection

Throws:
java.sql.SQLException

cleanDB

void cleanDB()
             throws java.sql.SQLException
Clear all RDF information from the database. All the Jena RDF tables are dropped. This wipes all the information stored by Jena from the database. Obviously should be used with care. The next atempt to open a DB model will (attempt to) recreate the Jena tables.

Throws:
java.sql.SQLException

isFormatOK

boolean isFormatOK()
                   throws RDFRDBException
Return true if the database seems to be formated for RDF storage. This is not an integrity check this is simply a flag recording that a base level table exists. Any access errors are treated as the database not being formated.

Throws:
RDFRDBException

setDatabaseProperties

void setDatabaseProperties(Model propertyModel)
                           throws RDFRDBException
Sets database-specific properties.

These properties may only be set before the first Model has been stored in the database. After that point, the database structure is frozen.

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

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

Note that some implementations may choose to delay actually peforming the formatting operation until at least one Graph is constructed in the database. Consequently, a successful return from this call does not necessarily guarantee that the database properties were set correctly.

Parameters:
propertyModel - is a Model describing the database parameters
Throws:
RDFRDBException
Since:
Jena 2.0

getDatabaseProperties

Model getDatabaseProperties()
                            throws RDFRDBException
Returns a Jena Model containing database properties.

These describe the optimization/layout for the database.

If the database has not been formatted, then a default set of properties is returned. Otherwise the actual properties are returned.

The returned Model is a copy, modifying it will have no effect on the database. (Use setDatabaseProperties to make changes).

Throws:
RDFRDBException
Since:
Jena 2.0

setDatabaseType

void setDatabaseType(java.lang.String databaseType)
Set the database type manually.

This is not for public use (it is preferable to specify it in the constructor) - included here to handle older code, which didn't use the new constructor.

Since:
Jena 2.0

getDefaultModelProperties

Model getDefaultModelProperties()
                                throws RDFRDBException
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);

Returns:
Model containing default properties
Throws:
RDFRDBException

getDatabaseType

java.lang.String getDatabaseType()
Get the database type.

Returns:
String database type, or null if unset
Since:
Jena 2.0

getAllModelNames

com.hp.hpl.jena.util.iterator.ExtendedIterator<java.lang.String> getAllModelNames()
                                                                                  throws RDFRDBException
Retrieve a list of all models in the database

Returns:
Iterator over String names for graphs.
Throws:
RDFDBException
RDFRDBException
Since:
Jena 2.0

containsModel

boolean containsModel(java.lang.String name)
                      throws RDFRDBException
Test if a given model is contained in the database.

Parameters:
name - the name of a model which may be in the database
Returns:
Boolean true if the model is contained in the database
Throws:
RDFDBException
RDFRDBException
Since:
Jena 2.0

containsDefaultModel

boolean containsDefaultModel()
                             throws RDFRDBException
Test if a default model is contained in the database. A default model is a model for which no specific name was specified. (One that was created by calling ModelRDB.createModel without specifying a name).

Returns:
Boolean true if the model is contained in the database
Throws:
RDFDBException
RDFRDBException
Since:
Jena 2.0

getDriver

com.hp.hpl.jena.db.impl.IRDBDriver getDriver()
                                             throws RDFRDBException
Get the database-specific driver For this to work, it needs to know the type of database being used. That may be specified in the constructor (preferred) or done later by using the setDatabaseType method (for backward compatability).

Throws:
RDFRDBException

setDriver

void setDriver(com.hp.hpl.jena.db.impl.IRDBDriver driver)
Set the IRDBDriver to use for this connection. Useful to enable external drivers to be registered outside of the standard driver package.



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