Update the Configuration File for Db2 Datastores

You should only create or update a configuration file using the dbfhconfig command line utility.

  1. Open an command prompt.
  2. Set the MFDBFH_CONFIG environment variable to locate the configuration file to be created or updated:
    set MFDBFH_CONFIG=<location-and-name-of-file>

    If you do not set this variable, a file named MFDBFH.cfg is assumed to be located in the current directory.

    Note: The MFDBFH_SCRIPT_DIR environment variable is also required to point to the stored procedures used to interact with a datastore; however, this variable is implicitly set already when using an command prompt.
  3. Add a database server instance that you intend to connect to:
    dbfhconfig -add -server:<server-name> -provider:db2

    where <server-name> is the name of the database server instance. An entry of localhost:<port> is also valid, which defaults to your machine name. If you have already updated the configuration file with the Db2 datastores, this entry will already exist, and you will receive a message informing you of this; you can skip to the next step.

    Now specify the required databases within the instance.

  4. Repeat the following step for each required datastore:
    dbfhconfig -add -server:<server-name> -dsn:<dsn-name> [-db:<existing-db>] -type:datastore -optio:<opts> -name:<dsname> [-user:<user-name>] [-password:<password>] [-bitism:<bit>] [-connect:<connection-string>]

    where <dsn-name> is the ODBC data source for the datastore, or if you are using a connection string (instead of an ODBC data source), it is a unique name within the Db2 configuration in which to reference the datastore; <existing-db> (which is optional) is the name of an existing database in which to store the datastore - if this option is omitted, a new database is created; <opts> are the optimizations to be applied to I/O operations, <dsname> is the actual name of the datastore (as configured in the data source properties); <user-name> and <password> are valid credentials for the instance - you do not need to specify theses if you are using a connection string; <bit> is the bitism of the associated ODBC data source - you do not need to specify this if you are using a connection string; and <connection-string> is the database connection string if you are establishing a database connection without the use of an ODBC data source - see Database Connection Strings for the database-specific syntax.

    <opts> can be one of:
    option description
    all All optimizations applied, as if +<opt> had been specified for each available option. You can then selectively disable certain options using -<opt>.
    none No optimizations applied.
    {+|-}oiseq Enables (+) or disables (-) optimizations for line-sequential files opened for input.
    {+|-}ooseq Enables (+) or disables (-) optimizations for line-sequential files opened for output.
    {+|-}oi Enables (+) or disables (-) optimizations for ESDS, KSDS, and RRDS files opened for input.
    {+|-}oo Enables (+) or disables (-) optimizations for ESDS, KSDS, and RRDS files opened for output.

Example configuration file

The following is an example of a configuration file that contains a datastore, a region database, and a cross-region database, using direct connection syntax. As the login credentials are required to establish a connection to this database, the secrets vault has also been enabled: see Configure a Secrets Vault for the Micro Focus Database File Handler for more information.

<datastores usevault="true">
   <server name="localhost:50000" type="db2" access="odbc">
      <dsn name="DB2.VSAM" type="datastore" dsname="VSAM" optio="none +ooseq" dbname="MYMFFILS" connect="$$vault$$"/>
      <dsn name="DB2.SEQ" type="datastore" dsname="VSAM" optio="none +ooseq" bitism:"32" userid="db2admin" password="$$vault$$"/>
      <dsn name="DB2.ESDEMO" type="region.cas" region="ESDEMO" feature="all" dbname="MYMFFILS" connect="$$vault$$"/>
      <dsn name="DB2.CROSSREGION" type="crossregion.cas" dsname="$XREGN$" dbname="MYMFFILS" connect="$$vault$$"/>
   </server>
</datastores>

If you have not already created the databases using the SQL script files, you must use the dbfhadmin command line utility to run the scripts; after which, use dbfhdeploy to add files to the datastores.