+

Search Tips   |   Advanced Search

Configure Apache Tomcat for DB2 manually

To manually set up and configure the DB2 database with Apache Tomcat server, use the following procedure.

Complete the DB2 Database Setup procedure before continuing.

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

    We 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 Configure 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;"/>
      <Resource auth="Container"
                driverClassName="com.ibm.db2.jcc.DB2Driver"
                name="jdbc/WorklightReportsDS"
                username="worklight"
                password="password"
                type="javax.sql.DataSource"
                url="jdbc:db2://db2server:50000/WLREPORT:currentSchema=WLRESCHM;"/>

    Where worklight after username= is the name of the system user with "CONNECT" access to the WRKLGHT and WLREPORT databases that you previously created, and password after password= is this user's password. If we 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).

    The database user provided in this step does not need extended privileges on the databases. If we need to implement restrictions on the database, we can set here a user that has the restricted privileges listed in Restrict database user permissions for runtime operations.

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


Parent topic: Configure the DB2 databases manually