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 ROUTING_TABLE table, 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 into the document, which creates the ROUTING database and runs the BIND utility. Name the file routing1.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 routing1.sql and enter the following command:
    db2 -vf routing1.sql
  4. Open a new document in a text editor. Copy and paste the following script into the document, which creates and populates the ROUTING_TABLE table. Name the file routing2.sql and save the file.
    CONNECT TO ROUTING
    DROP TABLE ROUTING_TABLE
    CREATE TABLE ROUTING_TABLE (Variable1 varchar(32),Variable2 varchar(32),Variable3 varchar(32), queue_manager varchar(48),queue_name varchar(48))
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'default','default',     'MB8QMGR', 'ROUTING.DEFAULT')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'TD',     'Montana',     'MB8QMGR', 'ROUTING.OUT1')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'DL',     'Corleone',    'MB8QMGR', 'ROUTING.OUT2')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'AA',     'Pacino',      'MB8QMGR', 'ROUTING.OUT3')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'RJ',     'DeNiro',      'MB8QMGR', 'ROUTING.OUT4')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'KF',     'Cobain',      'MB8QMGR', 'ROUTING.OUT5')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'JE',     'Matrix',      'MB8QMGR', 'ROUTING.OUT6')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'PL',     'Parker',      'MB8QMGR', 'ROUTING.OUT7')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'CJ',     'Kent',        'MB8QMGR', 'ROUTING.OUT8')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'MA',     'Douglas',     'MB8QMGR', 'ROUTING.OUT9')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'JD',     'Travolta',    'MB8QMGR', 'ROUTING.OUT10')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'HO',     'Ramsden',     'MB8QMGR', 'ROUTING.OUT11')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'KA',     'Stewart',     'MB8QMGR', 'ROUTING.OUT12')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'LS',     'Skywalker',   'MB8QMGR', 'ROUTING.OUT13')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'KD',     'Minogue',     'MB8QMGR', 'ROUTING.OUT14')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'PP',     'Pitstop',     'MB8QMGR', 'ROUTING.OUT15')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'JA',     'Reeve',       'MB8QMGR', 'ROUTING.OUT16')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'JA',     'Hetfield',    'MB8QMGR', 'ROUTING.OUT17')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'DT',     'Zuko',        'MB8QMGR', 'ROUTING.OUT18')
    INSERT INTO ROUTING_TABLE VALUES('SAMPLE_QUEUES', 'KA',     'Braithwaite', 'MB8QMGR', 'ROUTING.OUT19')
    TERMINATE
    
  5. In a DB2 command window, navigate to the folder that contains routing2.sql and enter the following command:
    db2 -vf routing2.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:

    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.ROUTING_TABLE" is an undefined name. SQLSTATE=42704
    

    Ignore this message. The message is displayed because the script attempts to remove an existing table called ROUTING_TABLE before it creates a new table but, if you have not run the script before, the script cannot find an existing table.

  6. Create an ODBC definition for the ROUTING database with ROUTING as the data source name (DSN).

    For instructions, see Enabling ODBC connections to the databases in the WebSphere Message Broker documentation.

Back to Setting up the database

Back to sample home