IBM Books

Building Applications for UNIX** Environments


Creating, Cataloging, and Binding the Sample Database

To use the examples in this book, you need to create 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.

Creating

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

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

  1. Ensure the location of db2sampl (the program that creates 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 create the sample database.

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

    db2sampl path

    On OS/2, Windows NT and Windows 95, 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 for UNIX book.

Creating on DRDA-Compliant Application Servers

If you want to run the sample programs against a DRDA-compliant application server, such as DB2 for OS/390, you need to create a database that contains the sample 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. Create the sample database in a DB2 server instance using db2sampl.

  2. Connect to the sample database.

  3. Export the sample tables to a file.

  4. Connect to the DRDA-compliant database.

  5. Create the sample tables.

  6. Import the sample 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 for UNIX 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 for UNIX 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 created 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 OS/390

    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 for UNIX 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 ]