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 DBConnection

    java.lang.Object
      com.hp.hpl.jena.db.DBConnection

All Implemented Interfaces:
  IDBConnection

    public class DBConnection

extends java.lang.Object
implements IDBConnection

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

Version:
  $Revision: 1.19 $
Author:
  csayers (based in part on the jena 1 implementation by der).

Constructor Summary
`DBConnection(java.sql.Connection connection)` Deprecated. As of Jena 2.0, it is recommended to use one of the DBConnection constructors which takes a database type as an argument. (The DBConnection can operate more efficiently if it knows the database type).
`DBConnection(java.sql.Connection connection, java.lang.String databaseType)` Create a connection specification that just wraps up an existing database connection.
`DBConnection(java.lang.String url, java.lang.String user, java.lang.String password)` Deprecated. As of Jena 2.0, it is recommended to use one of the DBConnection constructors which takes a database type as an argument. (The DBConnection can operate more efficiently if it knows the database type).
`DBConnection(java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String databaseType)` Create a connection specification based on jdbc address and appropriate authentication information.

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.
`ExtendedIterator` | `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.
`com.hp.hpl.jena.db.impl.IRDBDriver` | `getDriver(java.lang.String layout, java.lang.String database)` Deprecated. As of Jena 2.0 this call should not be used. Instead specify the database type when constructing a DBConnection and then pass that connection to the GraphRDB. There is no longer any need for applications to interact with the IRDBDriver. To customize the database configuration/layout use the formatDB(propertyModel) call.
`boolean` | `isFormatOK()` Return true if the database seems to be formated for RDF storage.
`void` | `setDatabaseProperties(Model dbProperties)` 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.

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

Constructor Detail

### DBConnection

    public DBConnection(java.lang.String url,
                        java.lang.String user,
                        java.lang.String password)

  Deprecated. As of Jena 2.0, it is recommended to use one of the DBConnection constructors which takes a database type as an argument. (The DBConnection can operate more efficiently if it knows the database type).

  Create a connection specification based on jdbc address and appropriate authentication information.

  Parameters:
    `url` - the jdbc url for the database, note that the format of this is database dependent and that the appropriate jdbc driver will need to be specified via the standard pattern

             Class.forName("my.sql.driver");

    `user` - the user name to log on with
    `password` - the password corresponding to this user

### DBConnection

    public DBConnection(java.lang.String url,
                        java.lang.String user,
                        java.lang.String password,
                        java.lang.String databaseType)

  Create a connection specification based on jdbc address and appropriate authentication information.

  Parameters:
    `url` - the jdbc url for the database, note that the format of this is database dependent and that the appropriate jdbc driver will need to be specified via the standard pattern

             Class.forName("my.sql.driver");

    `user` - the user name to log on with
    `password` - the password corresponding to this user
    `databaseType` - the type of database to which we are connecting.
  Since:
    Jena 2.0

### DBConnection

    public DBConnection(java.sql.Connection connection)

  Deprecated. As of Jena 2.0, it is recommended to use one of the DBConnection constructors which takes a database type as an argument. (The DBConnection can operate more efficiently if it knows the database type).

  Create a connection specification that just wraps up an existing database connection.

  Parameters:
    `connection` - the open jdbc connection to use

### DBConnection

    public DBConnection(java.sql.Connection connection,
                        java.lang.String databaseType)

  Create a connection specification that just wraps up an existing database connection.

  Parameters:
    `connection` - the open jdbc connection to use
    `databaseType` - the type of database to which we are connecting.
  Since:
    Jena 2.0

Method Detail

### getConnection

    public java.sql.Connection getConnection()
                                      throws java.sql.SQLException

  Description copied from interface: `IDBConnection`
  Return the jdbc connection or null if we no longer have access to a connection.

  Specified by:
    `getConnection` in interface `IDBConnection`
  Throws:
    `java.sql.SQLException`

### close

    public void close()
               throws java.sql.SQLException

  Description copied from interface: `IDBConnection`
  Close the jdbc connection

  Specified by:
    `close` in interface `IDBConnection`
  Throws:
    `java.sql.SQLException`

### cleanDB

    public void cleanDB()
                 throws java.sql.SQLException

  Description copied from interface: `IDBConnection`
  Clear all RDF information from the database. This wipes all the information stored by Jena from the database. Obviously should be used with care.

  Specified by:
    `cleanDB` in interface `IDBConnection`
  Throws:
    `java.sql.SQLException`

### isFormatOK

    public boolean isFormatOK()

  Description copied from interface: `IDBConnection`
  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.

  Specified by:
    `isFormatOK` in interface `IDBConnection`

### setDatabaseProperties

    public void setDatabaseProperties(Model dbProperties)
                               throws RDFRDBException

  Description copied from interface: `IDBConnection`
  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.

  Specified by:
    `setDatabaseProperties` in interface `IDBConnection`
  Parameters:
    `dbProperties` - is a Model describing the database parameters
  Throws:
    `RDFRDBException`

### getDatabaseProperties

    public Model getDatabaseProperties()
                                throws RDFRDBException

  Description copied from interface: `IDBConnection`
  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).

  Specified by:
    `getDatabaseProperties` in interface `IDBConnection`
  Throws:
    `RDFRDBException`

### getDefaultModelProperties

    public Model getDefaultModelProperties()
                                    throws RDFRDBException

  Description copied from interface: `IDBConnection`
  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);

  Specified by:
    `getDefaultModelProperties` in interface `IDBConnection`
  Returns:
    Model containing default properties
  Throws:
    `RDFRDBException`

### getAllModelNames

    public ExtendedIterator getAllModelNames()
                                      throws RDFRDBException

  Description copied from interface: `IDBConnection`
  Retrieve a list of all models in the database

  Specified by:
    `getAllModelNames` in interface `IDBConnection`
  Returns:
    Iterator over String names for graphs.
  Throws:
    `RDFRDBException`

### containsModel

    public boolean containsModel(java.lang.String name)
                          throws RDFRDBException

  Description copied from interface: `IDBConnection`
  Test if a given model is contained in the database.

  Specified by:
    `containsModel` in interface `IDBConnection`
  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:
    `RDFRDBException`

### containsDefaultModel

    public boolean containsDefaultModel()
                                 throws RDFRDBException

  Description copied from interface: `IDBConnection`
  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).

  Specified by:
    `containsDefaultModel` in interface `IDBConnection`
  Returns:
    Boolean true if the model is contained in the database
  Throws:
    `RDFRDBException`

### setDatabaseType

    public void setDatabaseType(java.lang.String databaseType)

  Description copied from interface: `IDBConnection`
  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.

  Specified by:
    `setDatabaseType` in interface `IDBConnection`

### getDatabaseType

    public java.lang.String getDatabaseType()

  Description copied from interface: `IDBConnection`
  Get the database type.

  Specified by:
    `getDatabaseType` in interface `IDBConnection`
  Returns:
    String database type, or null if unset

### getDriver

    public com.hp.hpl.jena.db.impl.IRDBDriver getDriver()
                                                 throws RDFRDBException

  Description copied from interface: `IDBConnection`
  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).

  Specified by:
    `getDriver` in interface `IDBConnection`
  Throws:
    `RDFRDBException`

### setDriver

    public void setDriver(com.hp.hpl.jena.db.impl.IRDBDriver driver)

  Description copied from interface: `IDBConnection`
  Set the IRDBDriver to use for this connection. Useful to enable external drivers to be registered outside of the standard driver package.

  Specified by:
    `setDriver` in interface `IDBConnection`

### getDriver

    public com.hp.hpl.jena.db.impl.IRDBDriver getDriver(java.lang.String layout,
                                                        java.lang.String database)
                                                 throws RDFRDBException

  Deprecated. As of Jena 2.0 this call should not be used. Instead specify the database type when constructing a DBConnection and then pass that connection to the GraphRDB. There is no longer any need for applications to interact with the IRDBDriver. To customize the database configuration/layout use the formatDB(propertyModel) call.

  Helper function to locate and instantiate the driver class corresponding to a given layout and database name Throws an RDFRDBexception if the driver can't be instantiated

  Specified by:
    `getDriver` in interface `IDBConnection`
  Throws:
    `RDFRDBException`

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