dbJFunk
    J2EE Application Generator 
 Philip Chauvet does Java, 
 J2EE, Web and Application Development.

Home
 
Download
Build
Deploy
Tomcat DB2
Tomcat ASCII
Deploying the Table Administrative Tool (TAD) DB2 Version to Apache TomCat.
 
1. Apache Tomcat
Download Apache Tomcat. The Apache Tomcat Project I have deployed TAD to Tomcat versions: 4.1 to 5.5.
 
2. Extract the dbadm.war
The dbadm.war was created from the ( build process ). Use Winzip, or its like, to extract the content of the dbadm.war J2EE Application to the Tomcat \webapps directory. I am deploying to the \webapps\dbadm directory.

       Note: My TomCat Datasource will points to this context - the dbadm directory.

 
Note:

I am working on getting the placement of the dbadm.war to the \webapps directory and letting Tomcat extract the contents. It's not behaving right now. Part of the TODO list.

 
3. The DB2 DataSource
Creating the JDBC DB2 Datasource within Tomcat. Go to the Tomcat \conf\server.xml file. Open this file in an editor and insert the following <Context> tag entries:
        <Context path="/dbadm" docBase="dbadm" debug="0"
                       reloadable="true" crossContext="true">
                <Logger className="org.apache.catalina.logger.FileLogger"
                           prefix="dbadm_log." suffix=".txt"
                    timestamp="true"/>

                <Environment name="maxExemptions" type="java.lang.Integer"
                            value="15"/>
                <Parameter name="context.param.name" value="context.param.value"
                           override="false"/>

                  <!-- Start DATABASE CONNECTION: DB2 -->
                <Resource name="jdbc/DBADM" auth="SERVLET" type="javax.sql.DataSource"/>
                <ResourceParams name="jdbc/DBADM">
                <!-- Use the apache Database Connection Pool -->
               <parameter>
                     <name>factory</name>
                     <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
               </parameter>
                <!-- Maximum number of dB connections in pool. Make sure you
                        configure your mysqld max_connections large enough to handle
                        all of your db connections. Set to 0 for no limit.
                        -->
                <parameter>
                  <name>maxActive</name>
                  <value>100</value>
                </parameter>
                <!-- Maximum number of idle dB connections to retain in pool.
                        Set to -1 for no limit.  See also the DBCP documentation on this
                        and the minEvictableIdleTimeMillis configuration parameter.
                        -->
                <parameter>
                  <name>maxIdle</name>
                  <value>30</value>
                </parameter>
                <!-- Maximum time to wait for a dB connection to become available
                        in ms, in this example 10 seconds. An Exception is thrown if
                        this timeout is exceeded.  Set to -1 to wait indefinitely.
                        -->
                <parameter>
                  <name>maxWait</name>
                  <value>10000</value>
                </parameter>
               <!-- To configure a DBCP DataSource so that abandoned dB connections
                  are removed and recycled add the following paramater to the
                  ResourceParams configuration for your DBCP DataSource Resource.
                  When available db connections run low DBCP will recover and recyle
                  any abandoned dB connections it finds. The default is false. -->
               <parameter>
                  <name>removeAbandoned</name>
                  <value>true</value>
               </parameter>
               <!-- Use the removeAbandonedTimeout parameter to set the number of
                   seconds a dB connection has been idle before it is considered abandoned.
                   The default timeout for removing abandoned connections is 300 seconds. -->
                   <parameter>
                    <name>removeAbandonedTimeout</name>
                    <value>60</value>
                  </parameter>
               <!-- The logAbandoned parameter can be set to true if you want DBCP to log a
                     stack trace of the code which abandoned the dB connection resources. -->
                   <parameter>
                    <name>logAbandoned</name>
                    <value>true</value>
                  </parameter>
               <!-- The typical JDBC Connection for DB2. My database was called DBADM -->
                  <parameter>
                     <name>username</name>
                     <value>db2admin</value>
                  </parameter>
                  <parameter>
                     <name>password</name>
                     <value>db2admin</value>
                  </parameter>
                  <parameter><name>driverClassName</name>
                    <value>COM.ibm.db2.jdbc.app.DB2Driver</value>
                  </parameter>
                  <parameter><name>url</name>
                    <value>jdbc:db2:DB2ADM</value>
                  </parameter>
                </ResourceParams>
                  <!-- End DATABASE CONNECTION: DB2 -->


                <Resource name="mail/Session" auth="Container"
                          type="javax.mail.Session"/>
                <ResourceParams name="mail/Session">
                  <parameter>
                    <name>mail.smtp.host</name>
                    <value>localhost</value>
                  </parameter>
                </ResourceParams>
                <ResourceLink name="linkToGlobalResource"
                          global="simpleValue"
                          type="java.lang.Integer"/>
              </Context>
Details of entries:
1. Creates the Context called /dbadm.
2. Creates the Resource name called jdbc/DBADM. My code is looking for this JDBC name.
3. Creates the DB2 driver parameter:
            <parameter><name>driverClassName</name>
              <value>COM.ibm.db2.jdbc.app.DB2Driver</value>
            </parameter>
4. Associates the driver with a DB2 schema name DBADM. I used the same name for the ODBC connection.
5. Associates the username and password:
            <parameter>
            <name>username</name>
            <value>db2admin</value>
            </parameter>
            <parameter>
            <name>password</name>
            <value>db2admin</value>
            </parameter>
 
Note:

A DB2 schema name called, DBADM, must be created. Remember the to create the table MYEXAMPLE within this schema:

CREATE TABLE DBADM.MYEXAMPLE
(
   RECID INTEGER,
   NAME VARCHAR(32),
   ADDRESS VARCHAR(50),
   PRIMARY CHAR(1)
);

I won't go into the how, but the DB2 environment should look like this.

 

 

 

 

 

 

An ODBC DataSource must also be created:

 

 
 
4. Start Tomcat
Tomcat's startup.bat should be executed, or however you start Tomcat. Tomcat will start with a similar message below:
Note:

A message should appear indicating that "DataSource name set to: --> jdbc/DBADM"

The J2EE Application is now up and running!
 
 
5. Accessing from the Browser
Open Internet Explorer with a URL as such: http://localhost:9080/dbadm/
 
6. The J2EE Application

The Table Administrative (TAD) Tool application should appear as such:
 
 
7. Login into the Application

Of course, what you see is a Login screen. 

You may not be able to Login since the Data Access Object (DAO) accessing this process is a flat file: SecureUser.txt. 
The deployed version uses two type of DAOs, flat files and DB2 to access the data.

 
There is a property file with points the Application to the flat file DAO SecureUser.txt file. The property file is located at: \webapps\dbadm\WEB-INF\classes\com\aikiinc\db\maintenance\secureuser\model\SecureuserProp.properties.
 
Within the SecureuserProp.properties point the Server to the correct file directory where you deployed Tomcat as such:
SECURE.TABLE_DIR=E:/jakarta-tomcat-4.1.24/webapps/dbadm/WEB-INF/classes/secureuser/
 
After making these changes, stop/restart Tomcat and try Login again. This is what you will see: TAD
 
8. Done
That's it, have fun using the J2EE Application:
TAD - Table Administrative Tool generated by
dbJFunk:
Talking Drums (Java/J2EE)!



I can always use the work!
I can be reached at  chauvetp@hotmail.com

(c) Aiki Innovations, 2004-2005