Configuring Apache Tomcat for DB2 manually

If you want to manually set up and configure your DB2® database with Apache Tomcat server, use the following procedure.

About this task

Complete the DB2 Database Setup procedure before continuing.

Procedure

  1. Add the DB2 JDBC driver JAR file to $TOMCAT_HOME/lib.

    You can retrieve the file in one of two ways:

  2. Prepare an XML statement that defines the data source, as shown in the following code example. Insert this statement in the server.xml file, as indicated in Configuring Apache Tomcat manually.
      <Resource auth="Container"
                driverClassName="com.ibm.db2.jcc.DB2Driver"
                name="jdbc/WorklightDS"
                username="worklight"
                password="password"
                type="javax.sql.DataSource"
                url="jdbc:db2://db2server:50000/WRKLGHT:currentSchema=WRKSCHM;"/>
    Where worklight after username= is the name of the system user with "CONNECT" access to the WRKLGHT database that you previously created, and password after password= is this user's password. If you have defined either a different user name, or a different password, or both, replace worklight accordingly. Also, replace db2server with the host name of your DB2 server (for example, localhost, if it is on the same machine).
    Note: The database user that is provided in this step does not need extended privileges on the databases. If you need to implement restrictions on the database, you can set here a user that has the restricted privileges that are listed in Restricting database user permissions for IBM MobileFirst™ Platform Server runtime operations.

    DB2 has a user name and password length limit of 8 characters for UNIX and Linux systems, and 30 characters for Windows.