DbLoad (Oracle - Berkeley DB Java Edition API)
Date: 2014-12-16

com.sleepycat.je.util

## Class DbLoad

- java.lang.Object
- - com.sleepycat.je.util.DbLoad

-     public class DbLoad
      extends Object

  Loads a database from a dump file generated by `DbDump`. This utility may be used programmatically or from the command line.

       java { com.sleepycat.je.util.DbLoad |
              -jar je-<version>.jar DbLoad }
           -h <dir>            # environment home directory
          [-f <fileName>]      # input file
          [-n ]                # no overwrite mode
          [-T]                 # input file is in text mode
          [-I]                 # ignore unknown parameters
          [-c name=value]      # config values
          [-s <databaseName> ] # database to load
          [-v]                 # show progress
          [-V]                 # print JE version number

  See `main(java.lang.String[])` for a full description of the command line arguments.

  To load a database to a stream from code:

          DbLoad loader = new DbLoad();
          loader.setEnv(env);
          loader.setDbName(dbName);
          loader.setInputStream(stream);
          loader.setNoOverwrite(noOvrwr);
          loader.setTextFileMode(tfm);
          loader.load();

  Because a `DATA=END` marker is used to terminate the dump of each database, multiple databases can be dumped and loaded using a single stream. The `DbDump.dump()` method leaves the stream positioned after the last line written and the `load()` method leaves the stream positioned after the last line read.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Environment` | `env`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DbLoad()` Creates a DbLoad object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `load()`
    `static void` | `main(String[] argv)` The main used by the DbLoad utility.
    `void` | `setDbName(String dbName)` Sets the database name to load.
    `void` | `setEnv(Environment env)` Sets the Environment to load from.
    `void` | `setIgnoreUnknownConfig(boolean ignoreUnknownConfigMode)` Sets whether to ignore unknown parameters in the config file.
    `void` | `setInputReader(BufferedReader reader)` Sets the BufferedReader to load from.
    `void` | `setNoOverwrite(boolean noOverwrite)` Sets whether the load should overwrite existing data or not.
    `void` | `setProgressInterval(long progressInterval)` If progressInterval is set, progress status messages are generated to stdout at set percentages of the load.
    `void` | `setTextFileMode(boolean textFileMode)` Sets whether the load data is in text file format.
    `void` | `setTotalLoadBytes(long totalLoadBytes)` Used for progress status messages.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### env

          protected Environment env

  - ### Constructor Detail

    - #### DbLoad

          public DbLoad()

      Creates a DbLoad object.

  - ### Method Detail

    - #### main

          public static void main(String[] argv)
                           throws Exception

      The main used by the DbLoad utility.
      Parameters:
        `argv` - The arguments accepted by the DbLoad utility.

             usage: java { com.sleepycat.je.util.DbLoad | -jar
             je-<version>.jar DbLoad }
                         [-f input-file] [-n] [-V] [-v] [-T] [-I]
                         [-c name=value]
                         [-s database] -h dbEnvHome

        -f - the file to load from (in DbDump format)
        -n - no overwrite mode. Do not overwrite existing data.
        -V - display the version of the JE library.
        -T - input file is in Text mode.
        -I - ignore unknown parameters in the config file.

        If -f is not specified, the dump is read from System.in.

        The -T option allows JE applications to easily load text files into databases.

        The -I option allows loading databases that were dumped with the Berkeley DB C product, when the dump file contains parameters not known to JE.

        The input must be paired lines of text, where the first line of the pair is the key item, and the second line of the pair is its corresponding data item.

        A simple escape mechanism, where newline and backslash (\) characters are special, is applied to the text input. Newline characters are interpreted as record separators. Backslash characters in the text will be interpreted in one of two ways: If the backslash character precedes another backslash character, the pair will be interpreted as a literal backslash. If the backslash character precedes any other character, the two characters following the backslash will be interpreted as a hexadecimal specification of a single character; for example, \0a is a newline character in the ASCII character set.

        For this reason, any backslash or newline characters that naturally occur in the text input must be escaped to avoid misinterpretation by db_load.

        -c name=value - Specify configuration options ignoring any value they may have based on the input. The command-line format is name=value. See the Supported Keywords section below for a list of keywords supported by the -c option.

        -s database - the database to load.
        -h dbEnvHome - the directory containing the database environment.
        -v - report progress

        Supported Keywords
        version=N - specify the version of the input file. Currently only version 3 is supported.
        format - specify the format of the file. Allowable values are "print" and "bytevalue".
        dupsort - specify whether the database allows duplicates or not. Allowable values are "true" and "false".
        type - specifies the type of database. Only "btree" is allowed.
        database - specifies the name of the database to be loaded.

      Throws:
        `EnvironmentFailureException` - if an unexpected, internal or environment-wide failure occurs.
        `Exception`

    - #### setEnv

          public void setEnv(Environment env)

      Sets the Environment to load from.
      Parameters:
        `env` - The environment.

    - #### setDbName

          public void setDbName(String dbName)

      Sets the database name to load.
      Parameters:
        `dbName` - database name

    - #### setInputReader

          public void setInputReader(BufferedReader reader)

      Sets the BufferedReader to load from.
      Parameters:
        `reader` - The BufferedReader.

    - #### setNoOverwrite

          public void setNoOverwrite(boolean noOverwrite)

      Sets whether the load should overwrite existing data or not.
      Parameters:
        `noOverwrite` - True if existing data should not be overwritten.

    - #### setTextFileMode

          public void setTextFileMode(boolean textFileMode)

      Sets whether the load data is in text file format.
      Parameters:
        `textFileMode` - True if the load data is in text file format.

    - #### setIgnoreUnknownConfig

          public void setIgnoreUnknownConfig(boolean ignoreUnknownConfigMode)

      Sets whether to ignore unknown parameters in the config file. This allows loading databases that were dumped with the Berkeley DB C product, when the dump file contains parameters not known to JE.
      Parameters:
        `ignoreUnknownConfigMode` - True to ignore unknown parameters in the config file.

    - #### setProgressInterval

          public void setProgressInterval(long progressInterval)

      If progressInterval is set, progress status messages are generated to stdout at set percentages of the load.
      Parameters:
        `progressInterval` - Specifies the percentage intervals for status messages. If 0, no messages are generated.

    - #### setTotalLoadBytes

          public void setTotalLoadBytes(long totalLoadBytes)

      Used for progress status messages. Must be set to greater than 0 if the progressInterval is greater than 0.
      Parameters:
        `totalLoadBytes` - number of input bytes to be loaded.

    - #### load

          public boolean load()
                       throws IOException,
                              DatabaseException

      Throws:
        `IOException`
        `DatabaseException`

Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.