UNIX: Create Datastore Data Sources for Db2

Note: We recommend that you use a connection string to connect to Db2 databases; that is, using the connect attribute within the database configuration file, which is covered in Update the Configuration File for Db2 Datastores.

If you did not use connection strings when configuring the database configuration file, use the following steps to create ODBC data sources to access the datastore databases.

There are a number of different driver managers that you can use to configure an ODBC data source. These instructions are carried out using unixODBC. If you are using a different driver manager, consult the vendor instructions for creating data sources.

  1. Run the command odbcinst -j command, and note down the location of the drivers configuration file (odbcinst.ini) and the user data sources configuration file (.odbc.ini).
  2. Open the odbcinst.ini configuration file and ensure that you have something similar to the following:

    (This may differ depending on the version of Db2 you are running.)

    [Db2]
    Description=Sample Db2 ODBC Database
    Driver=/opt/ibm/db2/dsdriver/lib/libdb20.so
  3. Open the .odbc.ini configuration file and add an entry for a datastore data source:
    [<datasource-name>]
    Driver = <driver-name>
    Server = <server-name>
    Port = <port-no>
    Database = <datastore-name>
    where:
    • <datasource-name> - a name for the data source.
    • <driver-name> - the name of the driver as configured in the .odbcinst.ini file; in the example above, that would be Db2.
    • <server-name> - the name of the server on which the database instance resides.
    • <port-no> - the port on which the database is listening.
    • <datastore-name> - the name of the datastore that you want to create.
  4. Repeat the last step for each additional datastore.
  5. Save the .odbc.ini configuration file.

Example .odbc.ini file

The following is an example of an .odbc.ini configuration file contains data sources for a local Db2 database instance with two datastores.

[Db2.VSAM]
Driver = Db2
Server = localhost
Port = 50000
Database = VSAM

[Db2.SEQFILES]
Driver = Db2
Server = localhost
Port = 50000
Database = SEQ

The data sources for the datastore databases are configured. You can now start to upload data files to them using the dbfhdeploy command line utility.