Class COM.odi.odmg.Database

java.lang.Object
   |
   +----COM.odi.odmg.Database

public final class Database
extends Object
The Database class represents a database and allows you to perform actions on a database.

The ODMG Database API is almost the same as the COM.odi.Database API. The COM.odi.odmg.Database methods bind(), lookup(), and unbind() replace the COM.odi.Database methods createRoot(), getRoot(), and destroyRoot(), respectively. The bind() method also replaces the setRoot() method depending on whether or not the named object (root) exists in the database.

You can view each ODMG database as either a regular ObjectStore database or an ODMG database. Call getODIDatabase() on the COM.odi.odmg.Database object to work in the nonODMG view. This allows you to, for example, store COM.odi.coll.* objects in ODMG databases.

See Also:
Database

Variable Index

 o notOpen
Flags that the access mode is not valid.
 o openExclusive
Same as openReadWrite mode.
 o openReadOnly
Database open mode for opening a readonly database.
 o openReadWrite
Database open mode for opening a database for update.

Method Index

 o bind(Object, String)
Binds an object to a name in the database.
 o close()
Closes a database.
 o create(String, int)
Creates and opens a database with the specified name.
 o getODIDatabase()
Obtains the current COM.odi.Database object that is associated with this COM.odi.odmg.Database object.
 o lookup(String)
Looks up a name in the database and returns the object associated with that name.
 o open(String, int)
Opens a database with the specified name.
 o unbind(String)
Unbinds the name from the object associated with it.

Variables

 o notOpen
  public final static int notOpen
Flags that the access mode is not valid.

 o openReadOnly
  public final static int openReadOnly
Database open mode for opening a readonly database. You can only read from the database in this mode.

 o openReadWrite
  public final static int openReadWrite
Database open mode for opening a database for update. You can make modifications to the database in this mode.

 o openExclusive
  public final static int openExclusive
Same as openReadWrite mode.

Methods

 o create
  public static Database create(String name,
                                int fileMode)
Creates and opens a database with the specified name. This method is not part of the ODMG interface, but ODMG does not suggest a method for creating a database, just opening an existing one. The fileMode argument corresponds to the modes in ObjectStore.

Parameters:
name - The name of the database being created. The name can be an absolute or relative file name. The name you specify or pass must end with the .odb extension. For example, myDatabase.odb is a valid name specification. The name is compatible with the name argument to the COM.odi.Database.create(java.lang.String, int) method.

fileMode - The Java mode to use when creating this database. The possible values for fileMode are the database creation constants for this class, which are interchangeable with the ObjectStore creation constants.

Returns:
An instance of Database that functions as a handle for the database.

Throws: AccessViolationException
If unable to create the database because of a file system access violation.
Throws: DatabaseAlreadyExistsException
If a database with the specified name already exists.
Throws: DatabaseException
If miscellaneous errors occur during database creation, such as an invalid path name or unknown host.
Throws: IllegalArgumentException
If the database name is null, or if the fileMode argument is invalid, including if the fileMode argument does not specify owner write permission.
Throws: ObjectStoreException
If there is no transaction associated with the current thread.
Throws: TransactionInProgressException
If there is a transaction in progress.
See Also:
open, open
 o open
  public static Database open(String name,
                              int accessMode)
Opens a database with the specified name. The accessMode argument is an ODMG access mode and is converted to the corresponding mode in ObjectStore.

Parameters:
name - The name of the database being opened. The name can be an absolute or relative path name. The name is compatible with the name argument to the COM.odi.Database.open(java.lang.String, int) method. The name you specify or pass must end with the .odb extension. For example, myDatabase.odb is a valid name specification.

accessMode - The Java mode to use when opening this database. The possible values for accessMode are openReadOnly, openReadWrite and openExclusive, which are NOT interchangeable with the ObjectStore constants.

Returns:
An instance of Database that functions as a handle for the database.

Throws: AccessViolationException
If ObjectStore is unable to read the database because of a file system access violation.
Throws: DatabaseNotFoundException
If a database with that name does not exist.
Throws: IllegalArgumentException
If the database name is null or if the accessMode parameter is invalid.
Throws: IncompatibleOpenModeException
If the specified database is already open, but with a different specification for accessMode.
Throws: ObjectStoreException
If there is no transaction associated with the current thread.
See Also:
open
 o close
  public void close()
Closes a database. After a call to this method, operations that require the database to be open throw COM.odi.DatabaseNotOpenException.

Throws: DatabaseClosedException
If the database is not open.
Throws: ObjectStoreException
If there is no transaction associated with the current thread or if the database object is not associated with the current transaction.
Throws: TransactionInProgressException
If a transaction is in progress.
See Also:
close
 o bind
  public void bind(Object object,
                   String name)
Binds an object to a name in the database. If the name does not exist, it creates the name in the database. If the name exists, it associates the name with this object. This method is the ODMG equivalent for ObjectStore's createRoot() and setRoot() methods. It provides the same behavior as both methods together.

Parameters:
object - The object that will become a root in the database.
name - The name that is bound to object.

Throws: DatabaseClosedException
If the database is not open.
Throws: DatabaseIsReadOnlyException
If there is a readonly transaction in progress or if the database is open readonly.
Throws: IllegalArgumentException
If the name argument is null.
Throws: ObjectNameNotUniqueException
If a root with that name already exists in the database.
Throws: ObjectNotExportedException
If the object is not exported and it is in a different database.
Throws: ObjectNotPersistenceCapableException
If the object is not persistence-capable and is not null.
Throws: ObjectStoreException
If there is no transaction associated with the current thread or if the database object is not associated with the current transaction.
Throws: TransactionNotInProgressException
If there is no transaction in progress.
See Also:
createRoot, setRoot
 o lookup
  public Object lookup(String name) throws DatabaseRootNotFoundException
Looks up a name in the database and returns the object associated with that name. This method is the ODMG equivalent to ObjectStore's getRoot() method.

Parameters:
name - The name to look up.

Returns:
A reference to the object associated with the root. A null return value indicates that the object associated with the root is null. It does not indicate the absence of the root.

Throws: DatabaseClosedException
If the database is not open.
Throws: IllegalArgumentException
If the name argument is null.
Throws: ObjectNameNotFoundException
If there is no root with the specified name in the database.
Throws: ObjectStoreException
If there is no transaction associated with the current thread or if the database object is not associated with the current transaction.
Throws: TransactionNotInProgressException
If there is no transaction in progress.
See Also:
getRoot
 o unbind
  public void unbind(String name) throws DatabaseRootNotFoundException
Unbinds the name from the object associated with it. This method is the ODMG equivalent to ObjectStore's destroyRoot() method.

Parameters:
name - The name of the root association to destroy.

Throws: DatabaseClosedException
If the database is not open.
Throws: DatabaseIsReadOnlyException
If there is a readonly transaction in progress or if the database is open for readonly.
Throws: IllegalArgumentException
If the name argument is null.
Throws: ObjectNameNotFoundException
If there is no root by that name in the database.
Throws: ObjectStoreException
If there is no transaction associated with the current thread or if the database object is not associated with the current transaction.
Throws: TransactionNotInProgressException
If there is no transaction in progress.
See Also:
destroyRoot
 o getODIDatabase
  public Database getODIDatabase()
Obtains the current COM.odi.Database object that is associated with this COM.odi.odmg.Database object.

Returns:
The COM.odi.Database associated with this Database.
See Also:
Database

Copyright © 1996, 1997, 1998 Object Design, Inc. All rights reserved.