Setting up DB2

These instructions assume that you are using DB2 Universal Database and guide you through the following tasks:

Note. When you create and access the SROUTEDB tables, be aware of the following issues:

Complete the following steps:

  1. Open a new document in a text editor, copy and paste the following script, which creates the SROUTEDB database and runs the BIND utility, into the document, name the file simplifieddbrouting1.sql and save the file.
  2. In a DB2 command window, enter the following command to ensure that DB2 is started:
    db2start
  3. In a DB2 command window, navigate to the folder that contains simplifieddbrouting1.sql and enter the following command:
    db2 -vf simplifieddbrouting1.sql
  4. Open a new document in a text editor, copy and paste the following script, which creates and populates the DEPARTMENT and EMPLOYEE tables, into the document, name the file simplifieddbrouting2.sql and save the file.
    CONNECT TO SROUTEDB
    DROP TABLE DEPARTMENT
    CREATE TABLE DEPARTMENT (DEPTNUM CHAR(3) NOT NULL, DEPTNAME VARCHAR(36) NOT NULL, MGRNUM CHAR(6))
    INSERT INTO DEPARTMENT  VALUES('D00', 'Personnel', '000010')
    INSERT INTO DEPARTMENT  VALUES('D01', 'Development', '000020')
    INSERT INTO DEPARTMENT  VALUES('D02', 'Support', '000030')
    DROP TABLE EMPLOYEE
    CREATE TABLE EMPLOYEE (EMPNUM CHAR(6) NOT NULL, FIRSTNM VARCHAR(20) NOT NULL, LASTNM VARCHAR(15) NOT NULL, PHONENUM CHAR(4), WORKDEPT CHAR(3), YEARSSERVICE INTEGER, AGEINYRS INTEGER, SEX CHAR(1), SALARY DECIMAL(9,2))
    INSERT INTO EMPLOYEE  VALUES('000010', 'DAVID', 'BROWN', '4501', 'D01', 10, 54, 'M', 23250.00)
    INSERT INTO EMPLOYEE  VALUES('000020', 'SALLY', 'KWAN', '4738', 'D00', 9, 27, 'F', 18375.00)
    INSERT INTO EMPLOYEE  VALUES('000030', 'JOHN', 'GEYER', '6789', 'D01', 22, 47, 'M', 53000.00)
    INSERT INTO EMPLOYEE  VALUES('000040', 'EVA', 'SMITH', '7831', 'D00', 12, 37, 'F', 29000.00)
    TERMINATE
          
  5. In a DB2 command window, navigate to the folder that contains simplifieddbrouting2.sql and enter the following command:
    db2 -vf simplifieddbrouting2.sql

    Wait for the script to finish running. If you are running the script for the first time, the following message is displayed, where DB2ADMIN is your user name and DEPARTMENT is the name of the table:

    DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command.
    During SQL processing it returned: SQL0204N "DB2ADMIN.DEPARTMENT" is an undefined name. SQLSTATE=42704
    Ignore these messages. The messages are displayed because the script attempts to remove any existing tables called DEPARTMENT and EMPLOYEE before it creates new tables, but if you have not run the script before, the script cannot find any existing tables.

You can now create the JDBCProvider definition, see Creating a JDBC provider entry for a DB2 database.

Back to Setting up the database

Back to sample home