IBM Books

Building Applications for UNIX** Environments


Installing, Cataloging, and Binding the SAMPLE Database

To use the examples in this book, you need to install the SAMPLE database on a server workstation. Refer to the SQL Reference for a listing of the contents of the SAMPLE database.

If you will be accessing the SAMPLE database on the server from a remote client, you need to catalog the SAMPLE database on the client workstation.

Also, if you will be accessing the SAMPLE database on the server from a remote client that is running a different version of DB2 or running on a different operating system, you need to bind the database utilities, including the DB2 CLI, to the SAMPLE database.

Installing

To create the SAMPLE database, you must have Administrator authority. If you need more information about Administrator authority, refer to the Quick Beginnings book.

To install the database, do the following on the server:

  1. Ensure the location of db2sampl (the program that installs the SAMPLE database) is in your path. The db2profile or db2cshrc file will put db2sampl in your path, so it will be there unless you change it.

  2. Set the DB2INSTANCE environment variable to the name of the instance where you want to install the SAMPLE database.

  3. Create the SAMPLE database by entering db2sampl followed by where you want to create the sample database. On UNIX-based systems, this is a path, and would be entered as:

    db2sampl path

    On OS/2 or Windows-based systems, this is a drive, and would be entered as:

    db2sampl drive

    If you do not specify the path or drive, the installation program installs the sample tables in the default path or drive specified by the DFTDBPATH parameter in the database manager configuration file. If you need information about the configuration file, refer to the Administration Guide.

    The authentication type for the database is the same as the instance in which it is created. If you need more information about specifying authentication when creating a database instance, refer to the Quick Beginnings book.

Installing on DRDA-Compliant Application Servers

If you want to run the sample programs against a DRDA-compliant application server, such as DB2 for MVS/ESA, you need to create a database that contains the sample STAFF and ORG tables described in the SQL Reference. You may want to refer to the sample program, expsamp, which uses the STAFF and ORG tables to demonstrate how APIs are used to import and export tables and table data to and from a DRDA database.

To create the database:

  1. Install the SAMPLE database in a DB2 common server instance using db2sampl.

  2. Connect to the SAMPLE database.

  3. Export the ORG and STAFF tables to a file.

  4. Connect to the DRDA-compliant database.

  5. Create the ORG and STAFF tables.

  6. Import the ORG and STAFF tables.

If you need information about exporting and importing files, refer to the Command Reference and the API Reference. If you need information about connecting to a database and creating tables, refer to the SQL Reference.

Cataloging

If you will be accessing the SAMPLE database on the server from a remote client, you need to catalog the SAMPLE database on the client workstation.

You do not need to catalog the SAMPLE database on the server workstation because it was cataloged when you created it.

Cataloging updates the database directory on the client workstation with the name of the database that the client application wants to access. When processing client requests, the database manager uses the cataloged name to find and connect to the database.

The Quick Beginnings book provides general information on cataloging databases. This section provides specific instructions on cataloging the SAMPLE database.

To catalog the sample database from the remote client workstation, enter:

db2 catalog database sample as sample at node nodename

where nodename is the name of the server node.

The Quick Beginnings book explains how to catalog nodes as part of setting up communication protocols. You must also catalog the remote node before you can connect to the database.

Binding

If you will be accessing the SAMPLE database on the server from a remote client that is running a different version of DB2 or running on a different operating system, you need to bind the database utilities, including the DB2 CLI, to the SAMPLE database.

To bind the database utilites, do the following on the client workstation:

  1. Connect to the SAMPLE database by entering:
    db2 connect to sample
    

  2. Bind the utilities to the database by entering:

    db2 bind BNDPATH/@db2ubind.lst blocking all sqlerror continue messages bind.msg

    db2 bind BNDPATH/@db2cli.lst blocking all sqlerror continue messages cli.msg

    where BNDPATH is the path where the bind files are located, such as $HOME/sqllib/bnd/, where $HOME is the home directory of the DB2 instance owner.
    Note:If you installed the SAMPLE database on a DRDA-compliant application server, specify one of the following .lst files instead of db2ubind.lst :

    ddcsmvs.lst
    for DB2 for MVS/ESA

    ddcsvse.lst
    for DB2 for VSE and VM

    ddcs400.lst
    for DB2 for OS/400

  3. Verify that the bind was successful by checking the bind message files bind.msg and cli.msg.

The Quick Beginnings book provides general information about binding the database utilities.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]