### XmlContainer.open |

`

###

    import com.sleepycat.dbxml.*;

    public void open(DbTxn txn, int flags, int mode)
        throws XmlException;

### Description: XmlContainer.open

The XmlContainer.open method opens the XmlContainer for reading and writing. The XmlContainer.open method may only be called on a closed container. A container is in the closed state after construction, and after the XmlContainer.close, XmlContainer.rename, or XmlContainer.remove methods have been called. A container can be reopened after it has been closed. The XmlContainer.isOpen method can be used to determine if a given container is currently open or closed.

A container is created using the XmlContainer.open method with the Db.DB_CREATE flag. The container is created without any indices specified. The XmlContainer.getIndexSpecification method can be used to retrieve the container indexing specification, the XmlIndexSpecification.addIndex method can be used to add indexing strategies, and the XmlContainer.setIndexSpecification method can be used to set the indexing specification for the container.

### Parameters

txn
  If the operation is to be transaction-protected, the txn parameter is a transaction handle returned from DbEnv.txnBegin, otherwise, NULL.

flags
  Specifies which modes the container will be opened in. The flags value must be set to zero, or a value created by bitwise inclusively OR'ing one or more of the following values:

  Db.DB_AUTO_COMMIT
    Automatically transact all update operations, unless the application provides a transaction handle.

  Db.DB_CREATE
    Create the XmlContainer if it does not already exist.

  Db.DB_DIRTY_READ
    Support reading of modified, but not yet committed data.

  Db.DB_EXCL
    Return an error if the container already exists. The Db.DB_EXCL flag is only meaningful when specified with the Db.DB_CREATE flag.

  Db.DB_NOMMAP
    Do not map this container into process memory (see DbEnv.setMemoryPoolMapSize for further information).

  Db.DB_RDONLY
    Open the XmlContainer for reading only. Subsequent attempts to modify the XmlContainer will fail.

  Db.DB_THREAD
    Cause the XmlContainer handle returned by XmlContainer.open to be free-threaded; that is, usable by multiple threads within a single address space.

    Threading is always assumed in the Java API, so no special flags are required, and Berkeley DB functions will always behave as if the Db.DB_THREAD flag was specified.

  Db.DBXML_CHKSUM_SHA1
    Do checksum verification of pages read into the cache from the backing filestore. Berkeley DB XML uses the SHA1 Secure Hash Algorithm if encryption is configured and a general hash algorithm if it is not.

  Db.DBXML_ENCRYPT
    Encrypt the database using the cryptographic password specified to the DbEnv.setEncrypted.

mode
  On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, all files created by XmlContainer.open are created with mode mode (as described in chmod(2)) and modified by the process' umask value at the time of creation (see umask(2)). If mode is 0, XmlContainer.open will use a default mode of readable and writable by both owner and group. On Windows systems, the mode parameter is ignored. The group ownership of created files is based on the system and directory defaults, and is not further specified by Berkeley DB.

### Throws

The XmlContainer.open method may fail and throw XmlException, encapsulating one of the following non-zero errors:

CONTAINER_EXISTS
  The DB_CREATE flag was specified, but the container already exists.

CONTAINER_OPEN
  The container is already open.

DATABASE_ERROR
  An error occurred in an underlying Berkeley DB database. The XmlException.getDbError method will return the error code for the error.

VERSION_MISMATCH
  The container version and dbxml library version differ; use the XmlContainer.upgrade method to update the container version.

### Class

XmlContainer, XmlDocument, XmlException, XmlIndexSpecification, XmlQueryContext, XmlQueryExpression, XmlResults, XmlUpdateContext, XmlValue`

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.