# Db

`

###

    import com.sleepycat.db.*;

    public class Db extends Object
    {
    	Db(DbEnv dbenv, int flags)
    		throws DbException;
    	...
    }

# Description

The Db handle is the handle for a Berkeley DB database, which may or may not be part of a database environment. Db handles are free-threaded if the Db.DB_THREAD flag is specified to the Db.open method when the database is opened or if the database environment in which the database is opened is free-threaded. The handle should not be closed while any other handle that refers to the database is in use; for example, database handles must not be closed while cursor handles into the database remain open, or transactions that include operations on the database have not yet been committed or aborted. Once the Db.close, Db.remove, or Db.rename methods are called, the handle may not be accessed again, regardless of the method's return.

The constructor creates a Db object that is the handle for a Berkeley DB database. The constructor allocates memory internally; calling the Db.close, Db.remove or Db.rename methods will free that memory.

If no dbenv value is specified, the database is standalone; that is, it is not part of any Berkeley DB environment.

If a dbenv value is specified, the database is created within the specified Berkeley DB environment. The database access methods automatically make calls to the other subsystems in Berkeley DB based on the enclosing environment. For example, if the environment has been configured to use locking, the access methods will automatically acquire the correct locks when reading and writing pages of the database.

The flags value must be set to 0 or by bitwise inclusively OR'ing together one or more of the following values:

Db.DB_XA_CREATE
  Instead of creating a standalone database, create a database intended to be accessed via applications running under a X/Open conformant Transaction Manager. The database will be opened in the environment specified by the OPENINFO parameter of the GROUPS section of the ubbconfig file. See the XA Resource Manager chapter in the Reference Guide for more information.

# Class

Db

# See Also

Databases and Related Methods`

Copyright Sleepycat Software