Determining if a DB2® instance is running

Technote (FAQ)
Problem
For the WebSphereŽ Application Server administrative server process to start successfully using DB2 as the administrative repository, the DB2 instance must be started and the database must be accessible.
Solution
DB2 has two sets of processes: global processes and instance processes (the processes that start with the db2start command are different). To verify that the DB2 instance is started and accessible, do the following:

Unix Platforms:
  • By default, the DB2 processes are started asynchronously from /etc/inittab. In theory, DB2 can be forced to start synchronously by changing the word "once" to "wait".
  • Simple shell commands to check the results of a connect:

    [root@aixwas1:/trash]-->su - db2inst1
    $ db2 connect to was
    Database Connection Information
    Database server = DB2/6000 6.1.0
    SQL authorization ID = DB2INST1
    Local database alias = WAS
    $ echo $?
    0
    $ db2 connect reset
    DB20000I The SQL command completed successfully.
    $ db2 connect to tunafish
    SQL1013N The database alias name or database name "TUNAFISH" could not
    be found. SQLSTATE=42705
    $ echo $?
    4
    $
  • Short script that can login using the DB2 instance owner id (for example, db2inst1) and check to see if DB2 is running. This can be run using root without changing root's profile.
    su - db2inst1 -c '. ~/.profile;db2 connect to was; echo $?; db2 connect reset;sleep 5;exit'

Windows Platforms:
  • DB2 typically is started as a service. Services are started asynchronously. It might take a few minutes to get DB2 started.
  • Set of DOS Batch commands that can check the connection:
    F:\>db2cmd

    F:\>db2 connect to was
    Database Connection Information
    Database server = DB2/NT 7.1.0
    SQL authorization ID = PERLOVL
    Local database alias = WAS

    F:\>if errorlevel 1 echo bad

    F:\>db2 connect reset
    DB20000I The SQL command completed successfully.

    F:\>db2 connect to tunafish
    SQL1013N The database alias name or database name "TUNAFISH" could not be
    found. SQLSTATE=42705

    F:\>if errorlevel 1 echo bad
    bad
    Cross Reference information
    SegmentProductComponentPlatformVersionEdition
    Application ServersWebSphere Application ServerDB Connections/Connection Pooling
    Historical Number
    PMR 15694
    49R











    Document Information

    Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, System Management/Repository
    Operating system(s): Multi-Platform
    Software version: 3.5, 4.0
    Software edition: Advanced, Standard
    Reference #: 1052429
    IBM Group: Software Group
    Modified date: 2004-01-14