Berkeley DB Java Edition
version 5.0.34

com.sleepycat.je
Class Environment

java.lang.Object
  extended by com.sleepycat.je.Environment
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
ReplicatedEnvironment, XAEnvironment

public class Environment
extends Object
implements Closeable

A database environment. Environments include support for some or all of caching, locking, logging and transactions.

To open an existing environment with default attributes the application may use a default environment configuration object or null:

      // Open an environment handle with default attributes.
     Environment env = new Environment(home, new EnvironmentConfig());
     
or
     Environment env = new Environment(home, null);
 

Note that many Environment objects may access a single environment.

To create an environment or customize attributes, the application should customize the configuration class. For example:

     EnvironmentConfig envConfig = new EnvironmentConfig();
     envConfig.setTransactional(true);
     envConfig.setAllowCreate(true);
     envConfig.setCacheSize(1000000);
     Environment newlyCreatedEnv = new Environment(home, envConfig);
 

Note that environment configuration parameters can also be set through the <environment home>/je.properties file. This file takes precedence over any programmatically specified configuration parameters so that configuration changes can be made without recompiling. Environment configuration follows this order of precedence:

  1. Configuration parameters specified in <environment home>/je.properties take first precedence.
  2. Configuration parameters set in the EnvironmentConfig object used at Environment construction are next.
  3. Any configuration parameters not set by the application are set to system defaults, described along with the parameter name String constants in the EnvironmentConfig class.

An environment handle is an Environment instance. More than one Environment instance may be created for the same physical directory, which is the same as saying that more than one Environment handle may be open at one time for a given environment.

The Environment handle should not be closed while any other handle remains open that is using it as a reference (for example, Database or Transaction. Once Environment.close is called, this object may not be accessed again.


Constructor Summary
Environment(File envHome, EnvironmentConfig configuration)
          Creates a database environment handle.
 
Method Summary
 Transaction beginTransaction(Transaction parent, TransactionConfig txnConfig)
          Creates a new transaction in the database environment.
 void checkpoint(CheckpointConfig ckptConfig)
          Synchronously checkpoint the database environment.
 int cleanLog()
          Synchronously invokes database environment log cleaning.
 void close()
          The Environment.close method closes the Berkeley DB environment.
 void compress()
          Synchronously invokes the compressor mechanism which compacts in memory data structures after delete operations.
 void evictMemory()
          Synchronously invokes the mechanism for keeping memory usage within the cache size boundaries.
 void flushLog(boolean fsync)
          Writes buffered data to the log, and optionally performs an fsync to guarantee that data is written to the physical device.
 EnvironmentConfig getConfig()
          Returns this object's configuration.
 List<String> getDatabaseNames()
          Returns a List of database names for the database environment.
 File getHome()
          Returns the database environment's home directory.
 LockStats getLockStats(StatsConfig config)
          Deprecated. as of 4.0.10, replaced by getStats(StatsConfig).

 EnvironmentMutableConfig getMutableConfig()
          Returns database environment attributes.
 EnvironmentStats getStats(StatsConfig config)
          Returns the general database environment statistics.
 Transaction getThreadTransaction()
          Returns the transaction associated with this thread if implied transactions are being used.
 TransactionStats getTransactionStats(StatsConfig config)
          Returns the database environment's transactional statistics.
protected  boolean isInternalHandle()
           
 boolean isValid()
          Returns whether this Environment is open, valid and can be used.
 Database openDatabase(Transaction txn, String databaseName, DatabaseConfig dbConfig)
          Opens, and optionally creates, a Database.
 SecondaryDatabase openSecondaryDatabase(Transaction txn, String databaseName, Database primaryDatabase, SecondaryConfig dbConfig)
          Opens and optionally creates a SecondaryDatabase.
 PreloadStats preload(Database[] databases, PreloadConfig config)
          Preloads the cache with multiple databases.
 void printStartupInfo(PrintStream out)
          Print a detailed report about the costs of different phases of environment startup.
 void removeDatabase(Transaction txn, String databaseName)
          Removes a database from the environment, discarding all records in the database and removing the database name itself.
 void renameDatabase(Transaction txn, String databaseName, String newName)
          Renames a database, without removing the records it contains.
 void setMutableConfig(EnvironmentMutableConfig mutableConfig)
          Sets database environment attributes.
 void setThreadTransaction(Transaction txn)
          Sets the transaction associated with this thread if implied transactions are being used.
 void sync()
          Synchronously flushes database environment databases to stable storage.
 long truncateDatabase(Transaction txn, String databaseName, boolean returnCount)
          Empties the database, discarding all the records it contains, without removing the database name.
 boolean verify(VerifyConfig config, PrintStream out)
          Returns if the database environment is consistent and correct.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Environment

public Environment(File envHome,
                   EnvironmentConfig configuration)
            throws EnvironmentNotFoundException,
                   EnvironmentLockedException,
                   VersionMismatchException,
                   DatabaseException,
                   IllegalArgumentException
Creates a database environment handle.

Parameters:
envHome - The database environment's home directory.
configuration - The database environment attributes. If null, default attributes are used.
Throws:
EnvironmentNotFoundException - if the environment does not exist (does not contain at least one log file) and the EnvironmentConfig AllowCreate parameter is false.
EnvironmentLockedException - when an environment cannot be opened for write access because another process has the same environment open for write access. Warning: This exception should be handled when an environment is opened by more than one process.
VersionMismatchException - when the existing log is not compatible with the version of JE that is running. This occurs when a later version of JE was used to create the log. Warning: This exception should be handled when more than one version of JE may be used to access an environment.
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
UnsupportedOperationException - if this environment was previously opened for replication and is not being opened read-only.
IllegalArgumentException - if an invalid parameter is specified, for example, an invalid EnvironmentConfig parameter.
DatabaseException
Method Detail

close

public void close()
           throws DatabaseException
The Environment.close method closes the Berkeley DB environment.

When the last environment handle is closed, allocated resources are freed, and daemon threads are stopped, even if they are performing work. For example, if the cleaner is still cleaning the log, it will be stopped at the next reasonable opportunity and perform no more cleaning operations.

The Environment handle should not be closed while any other handle that refers to it is not yet closed; for example, database environment handles must not be closed while database handles remain open, or transactions in the environment have not yet committed or aborted. Specifically, this includes Database, Cursor and Transaction handles.

If this handle has already been closed, this method does nothing and returns without throwing an exception.

In multithreaded applications, only a single thread should call Environment.close.

After this method has been called, regardless of its return, this Berkeley DB environment handle may not be accessed again, with one exception: the close method itself may be called any number of

WARNING: To guard against memory leaks, the application should discard all references to the closed handle. While BDB makes an effort to discard references from closed objects to the allocated memory for an environment, this behavior is not guaranteed. The safe course of action for an application is to discard all references to closed BDB objects.

Specified by:
close in interface Closeable
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if any open databases or transactions refer to this handle.
DatabaseException

openDatabase

public Database openDatabase(Transaction txn,
                             String databaseName,
                             DatabaseConfig dbConfig)
                      throws DatabaseNotFoundException,
                             DatabaseExistsException,
                             IllegalArgumentException,
                             IllegalStateException
Opens, and optionally creates, a Database.

Parameters:
txn - For a transactional database, an explicit transaction may be specified, or null may be specified to use auto-commit. For a non-transactional database, null must be specified.
databaseName - The name of the database.
dbConfig - The database attributes. If null, default attributes are used.
Returns:
Database handle.
Throws:
DatabaseExistsException - if the database already exists and the DatabaseConfig ExclusiveCreate parameter is true.
DatabaseNotFoundException - if the database does not exist and the DatabaseConfig AllowCreate parameter is false.
OperationFailureException - if one of the Read Operation Failures occurs. If the database does not exist and the AllowCreate parameter is true, then one of the Write Operation Failures may also occur.
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
IllegalArgumentException - if an invalid parameter is specified, for example, an invalid DatabaseConfig property.
IllegalStateException - if DatabaseConfig properties are changed and there are other open handles for this database.

openSecondaryDatabase

public SecondaryDatabase openSecondaryDatabase(Transaction txn,
                                               String databaseName,
                                               Database primaryDatabase,
                                               SecondaryConfig dbConfig)
                                        throws DatabaseNotFoundException,
                                               DatabaseExistsException,
                                               DatabaseException,
                                               IllegalArgumentException,
                                               IllegalStateException
Opens and optionally creates a SecondaryDatabase.

Note that the associations between primary and secondary databases are not stored persistently. Whenever a primary database is opened for write access by the application, the appropriate associated secondary databases should also be opened by the application. This is necessary to ensure data integrity when changes are made to the primary database.

Parameters:
txn - For a transactional database, an explicit transaction may be specified, or null may be specified to use auto-commit. For a non-transactional database, null must be specified.
databaseName - The name of the database.
primaryDatabase - the primary database with which the secondary database will be associated. The primary database must not be configured for duplicates.
dbConfig - The secondary database attributes. If null, default attributes are used.
Returns:
Database handle.
Throws:
DatabaseExistsException - if the database already exists and the DatabaseConfig ExclusiveCreate parameter is true.
DatabaseNotFoundException - if the database does not exist and the DatabaseConfig AllowCreate parameter is false.
OperationFailureException - if one of the Read Operation Failures occurs. If the database does not exist and the AllowCreate parameter is true, then one of the Write Operation Failures may also occur.
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
IllegalArgumentException - if an invalid parameter is specified, for example, an invalid SecondaryConfig property.
IllegalStateException - if DatabaseConfig properties are changed and there are other open handles for this database.
DatabaseException

removeDatabase

public void removeDatabase(Transaction txn,
                           String databaseName)
                    throws DatabaseNotFoundException
Removes a database from the environment, discarding all records in the database and removing the database name itself.

Compared to deleting all the records in a database individually, removeDatabase is a very efficient operation. Some internal housekeeping information is updated, but the database records are not read or written, and very little I/O is needed.

When called on a database configured with secondary indices, the application is responsible for also removing all associated secondary indices. To guarantee integrity, a primary database and all of its secondary databases should be removed atomically using a single transaction.

Applications should not remove a database with open Database handles. If the database is open with the same transaction as passed in the txn parameter, IllegalStateException is thrown by this method. If the database is open using a different transaction, this method will block until all database handles are closed, or until the conflict is resolved by throwing LockConflictException.

Parameters:
txn - For a transactional environment, an explicit transaction may be specified or null may be specified to use auto-commit. For a non-transactional environment, null must be specified.
databaseName - The database to be removed.
Throws:
DatabaseNotFoundException - if the database does not exist.
OperationFailureException - if one of the Write Operation Failures occurs.
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
UnsupportedOperationException - if this is a read-only environment.
IllegalStateException - if the database is currently open using the transaction passed in the txn parameter, or if this handle or the underlying environment has been closed.
IllegalArgumentException - if an invalid parameter is specified.

renameDatabase

public void renameDatabase(Transaction txn,
                           String databaseName,
                           String newName)
                    throws DatabaseNotFoundException
Renames a database, without removing the records it contains.

Applications should not rename a database with open Database handles. If the database is open with the same transaction as passed in the txn parameter, IllegalStateException is thrown by this method. If the database is open using a different transaction, this method will block until all database handles are closed, or until the conflict is resolved by throwing LockConflictException.

Parameters:
txn - For a transactional environment, an explicit transaction may be specified or null may be specified to use auto-commit. For a non-transactional environment, null must be specified.
databaseName - The new name of the database.
Throws:
DatabaseNotFoundException - if the database does not exist.
OperationFailureException - if one of the Write Operation Failures occurs.
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
UnsupportedOperationException - if this is a read-only environment.
IllegalStateException - if the database is currently open using the transaction passed in the txn parameter, or if this handle or the underlying environment has been closed.
IllegalArgumentException - if an invalid parameter is specified.

truncateDatabase

public long truncateDatabase(Transaction txn,
                             String databaseName,
                             boolean returnCount)
                      throws DatabaseNotFoundException
Empties the database, discarding all the records it contains, without removing the database name.

Compared to deleting all the records in a database individually, truncateDatabase is a very efficient operation. Some internal housekeeping information is updated, but the database records are not read or written, and very little I/O is needed.

When called on a database configured with secondary indices, the application is responsible for also truncating all associated secondary indices. To guarantee integrity, a primary database and all of its secondary databases should be truncated atomically using a single transaction.

Applications should not truncate a database with open Database handles. If the database is open with the same transaction as passed in the txn parameter, IllegalStateException is thrown by this method. If the database is open using a different transaction, this method will block until all database handles are closed, or until the conflict is resolved by throwing LockConflictException.

Parameters:
txn - For a transactional environment, an explicit transaction may be specified or null may be specified to use auto-commit. For a non-transactional environment, null must be specified.
databaseName - The database to be truncated.
returnCount - If true, count and return the number of records discarded.
Returns:
The number of records discarded, or -1 if returnCount is false.
Throws:
DatabaseNotFoundException - if the database does not exist.
OperationFailureException - if one of the Write Operation Failures occurs.
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
UnsupportedOperationException - if this is a read-only environment.
IllegalStateException - if the database is currently open using the transaction passed in the txn parameter, or if this handle or the underlying environment has been closed.
IllegalArgumentException - if an invalid parameter is specified.

getHome

public File getHome()
             throws DatabaseException
Returns the database environment's home directory.

Returns:
The database environment's home directory.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

beginTransaction

public Transaction beginTransaction(Transaction parent,
                                    TransactionConfig txnConfig)
                             throws DatabaseException,
                                    IllegalArgumentException
Creates a new transaction in the database environment.

Transaction handles are free-threaded; transactions handles may be used concurrently by multiple threads.

Cursors may not span transactions; that is, each cursor must be opened and closed within a single transaction. The parent parameter is a placeholder for nested transactions, and must currently be null.

Parameters:
txnConfig - The transaction attributes. If null, default attributes are used.
Returns:
The newly created transaction's handle.
Throws:
InsufficientReplicasException - if the Master in a replicated environment could not contact a quorum of replicas as determined by the Durability.ReplicaAckPolicy.
ReplicaConsistencyException - if a replica in a replicated environment cannot become consistent within the timeout period.
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
UnsupportedOperationException - if this is not a transactional environment.
IllegalStateException - if this handle or the underlying environment has been closed.
IllegalArgumentException - if an invalid parameter is specified, for example, an invalid TransactionConfig parameter.
DatabaseException

checkpoint

public void checkpoint(CheckpointConfig ckptConfig)
                throws DatabaseException
Synchronously checkpoint the database environment.

This is an optional action for the application since this activity is, by default, handled by a database environment owned background thread.

A checkpoint has the side effect of flushing all preceding non-transactional write operations, as well as any preceding transactions that were committed with no-sync durability. However, for best performance, checkpoints should be used only to bound recovery time. flushLog(boolean) can be used to write buffered data for durability purposes.

Parameters:
ckptConfig - The checkpoint attributes. If null, default attributes are used.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

sync

public void sync()
          throws DatabaseException
Synchronously flushes database environment databases to stable storage. Calling this method is equivalent to forcing a checkpoint and setting CheckpointConfig.setMinimizeRecoveryTime(boolean) to true.

A checkpoint has the side effect of flushing all preceding non-transactional write operations, as well as any preceding transactions that were committed with no-sync durability. However, for best performance, checkpoints should be used only to bound recovery time. flushLog(boolean) can be used to write buffered data for durability purposes.

Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

flushLog

public void flushLog(boolean fsync)
Writes buffered data to the log, and optionally performs an fsync to guarantee that data is written to the physical device.

This method is used to make durable, by writing to the log, all preceding non-transactional write operations, as well as any preceding transactions that were committed with no-sync durability. If the fsync parameter is true, it can also be used to flush all logged data to the physical storage device, by performing an fsync.

Note that this method does not flush previously unwritten data in deferred-write databases; that is done by calling Database.sync() or performing a checkpoint.

Parameters:
fsync - is true to perform an fsync as well as a file write, or false to perform only a file write.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.

cleanLog

public int cleanLog()
             throws DatabaseException
Synchronously invokes database environment log cleaning. This method is called periodically by the cleaner daemon thread.

Zero or more log files will be cleaned as necessary to bring the disk space utilization of the environment above the configured minimum utilization threshold. The threshold is determined by the EnvironmentConfig.CLEANER_MIN_UTILIZATION configuration setting.

Note that cleanLog does not perform the complete task of cleaning a log file. Eviction and checkpointing migrate records that are marked by the cleaner, and a full checkpoint is necessary following cleaning before cleaned files will be deleted (or renamed). Checkpoints normally occur periodically and when the environment is closed.

This is an optional action for the application since this activity is, by default, handled by one or more database environment owned background threads.

There are two intended use cases for the cleanLog method. The first case is where the application wishes to disable the built-in cleaner threads using the EnvironmentConfig.ENV_RUN_CLEANER property. To replace the functionality of the cleaner threads, the application should call cleanLog periodically.

In the second use case, "batch cleaning", the application disables the cleaner threads for maximum performance during active periods, and calls cleanLog during periods when the application is quiescent or less active than usual. If the cleaner has a large number of files to clean, cleanLog may stop without reaching the target utilization; to ensure that the target utilization is reached, cleanLog should be called in a loop until it returns zero. And to complete the work of cleaning, a checkpoint is necessary. An example of performing batch cleaning follows.

       Environment env;
       boolean anyCleaned = false;
       while (env.cleanLog() > 0) {
           anyCleaned = true;
       }
       if (anyCleaned) {
           CheckpointConfig force = new CheckpointConfig();
           force.setForce(true);
           env.checkpoint(force);
       }
 

WARNING:If batch cleaning (shown above) is performed immediately before closing the environment, then the built-in cleaner threads should normally be disabled using EnvironmentConfig.ENV_RUN_CLEANER during the batch cleaning process. If the built-in cleaner threads are actively working on one or more log files, then those files will not be processed by the cleanLog method. Closing the environment will abort the work being done by the built-in cleaner threads, and log cleaning may be incomplete.

Returns:
The number of log files that were cleaned, and that will be deleted (or renamed) when a qualifying checkpoint occurs.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
UnsupportedOperationException - if this is a read-only or memory-only environment.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

evictMemory

public void evictMemory()
                 throws DatabaseException
Synchronously invokes the mechanism for keeping memory usage within the cache size boundaries.

This is an optional action for the application since this activity is, by default, handled by a database environment owned background thread.

Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

compress

public void compress()
              throws DatabaseException
Synchronously invokes the compressor mechanism which compacts in memory data structures after delete operations.

This is an optional action for the application since this activity is, by default, handled by a database environment owned background thread.

Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

preload

public PreloadStats preload(Database[] databases,
                            PreloadConfig config)
                     throws DatabaseException
Preloads the cache with multiple databases. This method should only be called when there are no operations being performed on the specified databases in other threads. Executing preload during concurrent updates of the specified databases may result in some or all of the tree being loaded into the JE cache. Executing preload during any other types of operations may result in JE exceeding its allocated cache size. preload() effectively locks all of the specified database and therefore will lock out the checkpointer, cleaner, and compressor, as well as not allow eviction to occur.

Parameters:
config - The PreloadConfig object that specifies the parameters of the preload.
Returns:
A PreloadStats object with the result of the preload operation and various statistics about the preload() operation.
Throws:
OperationFailureException - if one of the Read Operation Failures occurs.
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if any of the databases has been closed.
DatabaseException
See Also:
Database.preload(PreloadConfig)

getConfig

public EnvironmentConfig getConfig()
                            throws DatabaseException
Returns this object's configuration.

Returns:
This object's configuration.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle has been closed.
DatabaseException

setMutableConfig

public void setMutableConfig(EnvironmentMutableConfig mutableConfig)
                      throws DatabaseException
Sets database environment attributes.

Attributes only apply to a specific Environment object and are not necessarily shared by other Environment objects accessing this database environment.

Parameters:
mutableConfig - The database environment attributes. If null, default attributes are used.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle has been closed.
DatabaseException

getMutableConfig

public EnvironmentMutableConfig getMutableConfig()
                                          throws DatabaseException
Returns database environment attributes.

Returns:
Environment attributes.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle has been closed.
DatabaseException

getStats

public EnvironmentStats getStats(StatsConfig config)
                          throws DatabaseException
Returns the general database environment statistics.

Parameters:
config - The general statistics attributes. If null, default attributes are used.
Returns:
The general database environment statistics.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

getLockStats

public LockStats getLockStats(StatsConfig config)
                       throws DatabaseException
Deprecated. as of 4.0.10, replaced by getStats(StatsConfig).

Returns the database environment's locking statistics.

Parameters:
config - The locking statistics attributes. If null, default attributes are used.
Returns:
The database environment's locking statistics.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

getTransactionStats

public TransactionStats getTransactionStats(StatsConfig config)
                                     throws DatabaseException
Returns the database environment's transactional statistics.

Parameters:
config - The transactional statistics attributes. If null, default attributes are used.
Returns:
The database environment's transactional statistics.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

getDatabaseNames

public List<String> getDatabaseNames()
                              throws DatabaseException
Returns a List of database names for the database environment.

Each element in the list is a String.

Returns:
A List of database names for the database environment.
Throws:
OperationFailureException - if one of the Read Operation Failures occurs.
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

verify

public boolean verify(VerifyConfig config,
                      PrintStream out)
               throws DatabaseException
Returns if the database environment is consistent and correct.

Verification is an expensive operation that should normally only be used for troubleshooting and debugging.

Parameters:
config - The verification attributes. If null, default attributes are used.
out - The stream to which verification debugging information is written.
Returns:
true if the database environment is consistent and correct.
Throws:
EnvironmentFailureException - if an unexpected, internal or environment-wide failure occurs.
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

getThreadTransaction

public Transaction getThreadTransaction()
                                 throws DatabaseException
Returns the transaction associated with this thread if implied transactions are being used. Implied transactions are used in an XA or JCA "Local Transaction" environment. In an XA environment the XAEnvironment.start() entrypoint causes a transaction to be created and become associated with the calling thread. Subsequent API calls implicitly use that transaction. XAEnvironment.end() causes the transaction to be disassociated with the thread. In a JCA Local Transaction environment, the call to JEConnectionFactory.getConnection() causes a new transaction to be created and associated with the calling thread.

Throws:
IllegalStateException - if this handle or the underlying environment has been closed.
DatabaseException

setThreadTransaction

public void setThreadTransaction(Transaction txn)
Sets the transaction associated with this thread if implied transactions are being used. Implied transactions are used in an XA or JCA "Local Transaction" environment. In an XA environment the XAEnvironment.start() entrypoint causes a transaction to be created and become associated with the calling thread. Subsequent API calls implicitly use that transaction. XAEnvironment.end() causes the transaction to be disassociated with the thread. In a JCA Local Transaction environment, the call to JEConnectionFactory.getConnection() causes a new transaction to be created and associated with the calling thread.

Throws:
IllegalStateException - if this handle or the underlying environment has been closed.

isValid

public boolean isValid()
Returns whether this Environment is open, valid and can be used. If this method returns false, close() should be called as soon as possible.

When an EnvironmentFailureException, or one of its subclasses, is caught, the isValid method should be called to determine whether the Environment can continue to be used, or should be closed.


printStartupInfo

public void printStartupInfo(PrintStream out)
Print a detailed report about the costs of different phases of environment startup. This report is by default logged to the je.info file if startup takes longer than je.env.startupThreshold.


isInternalHandle

protected boolean isInternalHandle()

Berkeley DB Java Edition
version 5.0.34

Copyright (c) 2004-2011 Oracle. All rights reserved.