Berkeley DB Java Edition version 3.2.13

## com.sleepycat.je
Class DatabaseConfig

    java.lang.Object
      com.sleepycat.je.DatabaseConfig

All Implemented Interfaces:
  Cloneable

Direct Known Subclasses:
  SecondaryConfig

    public class DatabaseConfig

extends Object
implements Cloneable

Specify the attributes of a database.

Field Summary
`static DatabaseConfig` `DEFAULT` An instance created using the default constructor is initialized with the system's default settings.

Constructor Summary
`DatabaseConfig()` An instance created using the default constructor is initialized with the system's default settings.

Method Summary
`DatabaseConfig` `cloneConfig()` Returns a copy of this configuration object.
`boolean` `getAllowCreate()` Return true if the `Environment.openDatabase` method is configured to create the database if it does not already exist.
`Comparator` `getBtreeComparator()` Returns the Comparator used for key comparison on this database.
`boolean` `getBtreeComparatorByClassName()`
`boolean` `getDeferredWrite()` Returns the setting for the deferred write option.
`Comparator` `getDuplicateComparator()` Returns the Comparator used for duplicate data item comparison on this database.
`boolean` `getDuplicateComparatorByClassName()`
`boolean` `getExclusiveCreate()` Return true if the `Environment.openDatabase` method is configured to fail if the database already exists.
`int` `getNodeMaxDupTreeEntries()` Return the maximum number of children a B+Tree duplicate tree node can have.
`int` `getNodeMaxEntries()` Return the maximum number of children a B+Tree node can have.
`boolean` `getOverrideBtreeComparator()` Returns the override setting for the btree comparator.
`boolean` `getOverrideDuplicateComparator()` Returns the override setting for the duplicate comparator.
`boolean` `getReadOnly()` Return true if the database is configured in read-only mode.
`boolean` `getSortedDuplicates()` Return true if the database is configured to support sorted duplicate data items.
`boolean` `getTransactional()` Return true if the database open is enclosed within a transaction.
`void` `setAllowCreate(boolean allowCreate)` Configure the `Environment.openDatabase` method to create the database if it does not already exist.
`void` `setBtreeComparator(Class btreeComparator)` By default, a byte by byte lexicographic comparison is used for btree keys.
`void` `setBtreeComparator(Comparator btreeComparator)` By default, a byte by byte lexicographic comparison is used for btree keys.
`void` `setDeferredWrite(boolean deferredWrite)` Open this database in deferred write mode.
`void` `setDuplicateComparator(Class duplicateComparator)` By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set.
`void` `setDuplicateComparator(Comparator duplicateComparator)` By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set.
`void` `setExclusiveCreate(boolean exclusiveCreate)` Configure the `Environment.openDatabase` method to fail if the database already exists.
`void` `setNodeMaxDupTreeEntries(int nodeMaxDupTreeEntries)` Configure the `Environment.openDatabase` method to have a B+Tree duplicate tree fanout of nodeMaxDupTreeEntries.
`void` `setNodeMaxEntries(int nodeMaxEntries)` Configure the `Environment.openDatabase` method to have a B+Tree fanout of nodeMaxEntries.
`void` `setOverrideBtreeComparator(boolean override)` Set to true if the database exists and the btree comparator specified in this configuration object should override the current comparator.
`void` `setOverrideDuplicateComparator(boolean override)` Set to true if the database exists and the duplicate comparator specified in this configuration object should override the current comparator.
`void` `setReadOnly(boolean readOnly)` Configure the database in read-only mode.
`void` `setSortedDuplicates(boolean sortedDuplicates)` Configure the database to support sorted, duplicate data items.
`void` `setTransactional(boolean transactional)` Enclose the database open within a transaction.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT

    public static final DatabaseConfig DEFAULT

  An instance created using the default constructor is initialized with the system's default settings.

Constructor Detail

### DatabaseConfig

    public DatabaseConfig()

  An instance created using the default constructor is initialized with the system's default settings.

Method Detail

### setAllowCreate

    public void setAllowCreate(boolean allowCreate)

  Configure the `Environment.openDatabase` method to create the database if it does not already exist.

  Parameters:
    `allowCreate` - If true, configure the `Environment.openDatabase` method to create the database if it does not already exist.

### getAllowCreate

    public boolean getAllowCreate()

  Return true if the `Environment.openDatabase` method is configured to create the database if it does not already exist.

  This method may be called at any time during the life of the application.

  Returns:
    True if the `Environment.openDatabase` method is configured to create the database if it does not already exist.

### setExclusiveCreate

    public void setExclusiveCreate(boolean exclusiveCreate)

  Configure the `Environment.openDatabase` method to fail if the database already exists.

  The exclusiveCreate mode is only meaningful if specified with the allowCreate mode.

  Parameters:
    `exclusiveCreate` - If true, configure the `Environment.openDatabase` method to fail if the database already exists.

### getExclusiveCreate

    public boolean getExclusiveCreate()

  Return true if the `Environment.openDatabase` method is configured to fail if the database already exists.

  This method may be called at any time during the life of the application.

  Returns:
    True if the `Environment.openDatabase` method is configured to fail if the database already exists.

### getSortedDuplicates

    public boolean getSortedDuplicates()

  Return true if the database is configured to support sorted duplicate data items.

  This method may be called at any time during the life of the application.

  Returns:
    True if the database is configured to support sorted duplicate data items.

### setReadOnly

    public void setReadOnly(boolean readOnly)

  Configure the database in read-only mode.

  Any attempt to modify items in the database will fail, regardless of the actual permissions of any underlying files.

  Parameters:
    `readOnly` - If true, configure the database in read-only mode.

### getReadOnly

    public boolean getReadOnly()

  Return true if the database is configured in read-only mode.

  This method may be called at any time during the life of the application.

  Returns:
    True if the database is configured in read-only mode.

### setSortedDuplicates

    public void setSortedDuplicates(boolean sortedDuplicates)

  Configure the database to support sorted, duplicate data items.

  Insertion when the key of the key/data pair being inserted already exists in the database will be successful. The ordering of duplicates in the database is determined by the duplicate comparison function.

  If the application does not specify a duplicate data item comparison function, a default lexical comparison will be used.

  If a primary database is to be associated with one or more secondary databases, it may not be configured for duplicates.

  Calling this method affects the database, including all threads of control accessing the database.

  If the database already exists when the database is opened, any database configuration specified by this method must be the same as the existing database or an error will be returned.

  Parameters:
    `sortedDuplicates` - If true, configure the database to support duplicate data items. A value of false is illegal to this method, that is, once set, the configuration cannot be cleared.

### setTransactional

    public void setTransactional(boolean transactional)

  Enclose the database open within a transaction.

  If the call succeeds, the open operation will be recoverable. If the call fails, no database will have been created.

  All future operations on this database, which are not explicitly enclosed in a transaction by the application, will be enclosed in in a transaction within the library.

  Parameters:
    `transactional` - If true, enclose the database open within a transaction.

### getTransactional

    public boolean getTransactional()

  Return true if the database open is enclosed within a transaction.

  This method may be called at any time during the life of the application.

  Returns:
    True if the database open is enclosed within a transaction.

### cloneConfig

    public DatabaseConfig cloneConfig()

  Returns a copy of this configuration object.

### setNodeMaxEntries

    public void setNodeMaxEntries(int nodeMaxEntries)

  Configure the `Environment.openDatabase` method to have a B+Tree fanout of nodeMaxEntries.

  The nodeMaxEntries parameter is only meaningful if specified with the allowCreate mode.

  Parameters:
    `nodeMaxEntries` - The maximum children per B+Tree node.

### setNodeMaxDupTreeEntries

    public void setNodeMaxDupTreeEntries(int nodeMaxDupTreeEntries)

  Configure the `Environment.openDatabase` method to have a B+Tree duplicate tree fanout of nodeMaxDupTreeEntries.

  The nodeMaxDupTreeEntries parameter is only meaningful if specified with the allowCreate mode.

  Parameters:
    `nodeMaxDupTreeEntries` - The maximum children per duplicate B+Tree node.

### getNodeMaxEntries

    public int getNodeMaxEntries()

  Return the maximum number of children a B+Tree node can have.

  This method may be called at any time during the life of the application.

  Returns:
    The maximum number of children a B+Tree node can have.

### getNodeMaxDupTreeEntries

    public int getNodeMaxDupTreeEntries()

  Return the maximum number of children a B+Tree duplicate tree node can have.

  This method may be called at any time during the life of the application.

  Returns:
    The maximum number of children a B+Tree duplicate tree node can have.

### setBtreeComparator

    public void setBtreeComparator(Class btreeComparator)

  By default, a byte by byte lexicographic comparison is used for btree keys. To customize the comparison, supply a different Comparator.

  Note that there are two ways to set the comparator: by specifying the class or by specifying a serializable object. This method is used to specify a Comparator class. The comparator class must implement java.util.Comparator and must have a public zero-parameter constructor. JE will store the class name and instantiate the Comparator by class name (using `Class.forName` and `newInstance`) when subsequently opening the database. Because the Comparator is instantiated using its default constructor, it should not be dependent on other constructor parameters.

  Because records are stored in the order determined by the Comparator, the Comparator's behavior must not change over time and therefore should not be dependent on any state that may change over time. In addition, although it is possible to change the comparator for an existing database, care must be taken that the new comparator provides compatible results with the previous comparator, or database corruption will occur.

  The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

  JE uses comparators internally in a wide variety of circumstances, so custom comparators must be sure to return valid values for any two arbitrary keys. The user must not make any assumptions about the range of key values that might be compared. For example, it's possible for the comparator may may be used against previously deleted values.

  The comparator for an existing database will not be overridden unless setOverrideBtreeComparator() is set to true.

### setBtreeComparator

    public void setBtreeComparator(Comparator btreeComparator)

  By default, a byte by byte lexicographic comparison is used for btree keys. To customize the comparison, supply a different Comparator.

  Note that there are two ways to set the comparator: by specifying the class or by specifying a serializable object. This method is used to specify a serializable object. The comparator class must implement java.util.Comparator and must be serializable. JE will serialize the Comparator and deserialize it when subsequently opening the database.

  Because records are stored in the order determined by the Comparator, the Comparator's behavior must not change over time and therefore should not be dependent on any state that may change over time. In addition, although it is possible to change the comparator for an existing database, care must be taken that the new comparator provides compatible results with the previous comparator, or database corruption will occur.

  The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

  JE uses comparators internally in a wide variety of circumstances, so custom comparators must be sure to return valid values for any two arbitrary keys. The user must not make any assumptions about the range of key values that might be compared. For example, it's possible for the comparator may may be used against previously deleted values.

  The comparator for an existing database will not be overridden unless setOverrideBtreeComparator() is set to true.

### getBtreeComparator

    public Comparator getBtreeComparator()

  Returns the Comparator used for key comparison on this database.

### getBtreeComparatorByClassName

    public boolean getBtreeComparatorByClassName()

  Returns:
    whether Comparator is set by class name, not by serializable Comparator object.

### setOverrideBtreeComparator

    public void setOverrideBtreeComparator(boolean override)

  Set to true if the database exists and the btree comparator specified in this configuration object should override the current comparator.

  Parameters:
    `override` - Set to true to override the existing comparator.

### getOverrideBtreeComparator

    public boolean getOverrideBtreeComparator()

  Returns the override setting for the btree comparator.

### getDuplicateComparatorByClassName

    public boolean getDuplicateComparatorByClassName()

  Returns:
    whether Comparator is set by class name, not by serializable Comparator object.

### setDuplicateComparator

    public void setDuplicateComparator(Class duplicateComparator)

  By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set. To customize the comparison, supply a different Comparator.

  Note that there are two ways to set the comparator: by specifying the class or by specifying a serializable object. This method is used to specify a Comparator class. The comparator class must implement java.util.Comparator and must have a public zero-parameter constructor. JE will store the class name and instantiate the Comparator by class name (using `Class.forName` and `newInstance`) when subsequently opening the database. Because the Comparator is instantiated using its default constructor, it should not be dependent on other constructor parameters.

  Because records are stored in the order determined by the Comparator, the Comparator's behavior must not change over time and therefore should not be dependent on any state that may change over time. In addition, although it is possible to change the comparator for an existing database, care must be taken that the new comparator provides compatible results with the previous comparator, or database corruption will occur.

  The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

  JE uses comparators internally in a wide variety of circumstances, so custom comparators must be sure to return valid values for any two arbitrary keys. The user must not make any assumptions about the range of key values that might be compared. For example, it's possible for the comparator may may be used against previously deleted values.

  The comparator for an existing database will not be overridden unless setOverrideDuplicateComparator() is set to true.

### setDuplicateComparator

    public void setDuplicateComparator(Comparator duplicateComparator)

  By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set. To customize the comparison, supply a different Comparator.

  Note that there are two ways to set the comparator: by specifying the class or by specifying a serializable object. This method is used to specify a serializable object. The comparator class must implement java.util.Comparator and must be serializable. JE will serialize the Comparator and deserialize it when subsequently opening the database.

  Because records are stored in the order determined by the Comparator, the Comparator's behavior must not change over time and therefore should not be dependent on any state that may change over time. In addition, although it is possible to change the comparator for an existing database, care must be taken that the new comparator provides compatible results with the previous comparator, or database corruption will occur.

  The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

  JE uses comparators internally in a wide variety of circumstances, so custom comparators must be sure to return valid values for any two arbitrary keys. The user must not make any assumptions about the range of key values that might be compared. For example, it's possible for the comparator may may be used against previously deleted values.

  The comparator for an existing database will not be overridden unless setOverrideDuplicateComparator() is set to true.

### getDuplicateComparator

    public Comparator getDuplicateComparator()

  Returns the Comparator used for duplicate data item comparison on this database.

### setOverrideDuplicateComparator

    public void setOverrideDuplicateComparator(boolean override)

  Set to true if the database exists and the duplicate comparator specified in this configuration object should override the current comparator.

  Parameters:
    `override` - Set to true to override the existing comparator.

### getOverrideDuplicateComparator

    public boolean getOverrideDuplicateComparator()

  Returns the override setting for the duplicate comparator.

### setDeferredWrite

    public void setDeferredWrite(boolean deferredWrite)

  Open this database in deferred write mode. Deferred write databases avoid disk I/O and are not guaranteed to be persistent until Database.sync() is called. This mode is particularly geared toward temporary databases, or databases that frequently modify and delete data records. See the Getting Started Guide, Database chapter for a full description of the mode.

  Note that although deferred write databases can page to disk if the cache is not large enough to hold the databases, they are much more efficient if the database remains in memory. See the JE FAQ on the Oracle Technology Network site for information on how to estimate the cache size needed by a given database. In the current implementation, a deferred write database which is synced or pages to the disk may also add additional log cleaner overhead to the environment. See the je.deferredWrite.temp property in <JEHOME>/example.properties for tuning information on how to ameliorate this cost.

  Parameters:
    `deferredWrite` - if true, the database will be opened in deferred write mode.

### getDeferredWrite

    public boolean getDeferredWrite()

  Returns the setting for the deferred write option.

  Returns:
    boolean if true, deferred write is enabled.

Berkeley DB Java Edition version 3.2.13

Copyright 1996,2006 Oracle. All rights reserved.