|
Objectivity for Java Reference | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.objy.db.app.Database
Represents an ODMG database.
API Summary |
The ODMG standard does not include the concept of a federation of databases; as a consequence, an ODMG database corresponds to an Objectivity/DB federated database in which all persistent objects are stored in the default database.
Methods of Database allow you to open and close a database and to store and retrieve persistent objects by their root names.
Note: Your application should work with an instance of this class only if it requires ODMG compliance; otherwise, it should work with a connection object instead. For additional information about ODMG applications, see ODMG Application Objects.
Constant Types | |
Open modes (ODMG) Specify how a connection to the federated database is opened. |
notOpen openReadOnly openReadWrite |
Functionality | |
Opening and Closing Databases | open(String, int) (ODMG) isOpen() close() (ODMG) |
Getting Information | current() getConnection() |
Testing | isOpen() |
Working With Named Roots | bind(Object, String) (ODMG) unbind(String) (ODMG) lookup(String) (ODMG) |
Static Utilities | open(String, int) (ODMG) current() |
Field Summary | |
static int |
notOpen
(ODMG) Open mode: The database is not open; transactions may not be created. |
static int |
openExclusive
(ODMG) Not supported. |
static int |
openReadOnly
(ODMG) Open mode: The database is open for read-only access. |
static int |
openReadWrite
(ODMG) Open mode: The database is open for read/write access. |
Constructor Summary | |
Database(PConnection persistor)
Reserved for internal use; to create an ODMG database object, call the static method Database.open. |
Method Summary | |
void |
bind(Object object,
String name)
(ODMG) Names the specified object with the specified root name in the connected federated database. |
void |
close()
(ODMG) Closes the connection associated with this ODMG database object. |
static Database |
current()
Gets this application's ODMG database object. |
Connection |
getConnection()
Gets the connection associated with this ODMG database object. |
boolean |
isOpen()
Tests whether the connection between the associated connection object and the federated database is open. |
Object |
lookup(String name)
(ODMG) Retrieves the object with the specified root name in the connected federated database. |
static Database |
open(String bootFilePath,
int mode)
(ODMG) Opens a connection to the specified federated database and returns the ODMG database object associated with the connection. |
void |
unbind(String name)
(ODMG) Removes the specified root name from the connected federated database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int notOpen
public static final int openReadOnly
public static final int openReadWrite
public static final int openExclusive
Constructor Detail |
public Database(PConnection persistor)
You should not use this constructor.
Method Detail |
public static Database open(String bootFilePath, int mode) throws DatabaseOpenException, DatabaseNotFoundException
You must open a connection before creating any transactions (or sessions) that interact with the federated database.
Note: There can be only one instance of the Database class in an application.
This method creates the connection object through which your application interacts with the federated database. You can obtain the connection object by calling the getConnection method of the returned ODMG database object.
bootFilePath
- The pathname of the
boot file of the federated database to which a connection is
being opened. If this parameter is an empty string ("") or
null,
the value of the OO_FD_BOOT environment variable is used
as the boot file path.mode
- The open mode for the new ODMG database
object; one of the following constants defined in this class (and also in
the oo interface):
The open mode limits the open mode of each session object created after the database is opened. As a consequence, it also limits the lock modes of any storage objects or persistent objects that belong to those sessions. A database open mode of openReadWrite permits session open modes of openReadWrite or openReadOnly; a database open mode of openReadOnly permits the session open mode openReadOnly.
DatabaseOpenException
- If a connection to the
federated database is already open.DatabaseNotFoundException
- If the federated database
doesn't exist.close()
,
isOpen()
public boolean isOpen()
open(java.lang.String, int)
,
close()
public static Database current()
public Connection getConnection()
public void close() throws DatabaseClosedException
This method terminates all sessions. It should be called before exiting from an application.
DatabaseClosedException
- If
this connection object is already closed.TransactionInProgressException
- If any transaction is
open without terminating any sessions and have the database open.isOpen()
,
open(java.lang.String, int)
public void bind(Object object, String name) throws ObjectNameNotUniqueException
Giving an object a root name makes the object persistent. The named object is made persistent immediately; all transient objects reachable from the named object are made persistent on transaction commit.
This method can be called only during a transaction.
object
- The object being named.name
- The root name for the object.
This name can be any valid Java string and must be unique
within the root dictionary of the federated database.ObjectNameNotUniqueException
- If the name already exists in the root
dictionary.unbind(java.lang.String)
,
ooFDObj.getDefaultDB()
public void unbind(String name) throws ObjectNameNotFoundException
This method can be called only during a transaction.
name
- The root name to be removed.ObjectNameNotFoundException
- If the name doesn't exist in the root
dictionary.public Object lookup(String name) throws ObjectNameNotFoundException
This method can be called only during a transaction.
name
- The root name of the object.ObjectNameNotFoundException
- If the name doesn't exist in the root
dictionary.
|
Objectivity for Java Reference | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2000 Objectivity, Inc. All rights reserved.