Tuesday, November 16, 2004

Setting up Tomcat for DB2 and some tips

NOTE:

  • These were tested on win2k
  • "C:\jakarta-slide-2.0-tomcat-5.0.19\" is mentioned as $CATALINA_HOME

Pre-Requisites:

  • DB2.
  • Latest Java SDK
Steps:

  • Set an Enviromental Variable "JAVA_HOME" to the Java SDK's Home Directory.
  • Download & Install the latest binaries from Apache's Site (Get *.exe for windows to install as a service)
  • Copy "C:\Program Files\IBM\SQLLIB\java\db2java.zip" file to C:\jakarta-slide-2.0-tomcat-5.0.19\common\lib\" and rename the file to db2java.jar.

Running Tomcat as Service (Windows)

  • If you have installed *.exe file you already have Tomcat running as a service.
  • An work around for this is to run the startup.bat as a schedule task on system startup. This doesn't shows the Tomcat's command window (This method doesn't really install Tomcat as service)

Changing Tomcat's 8080 Port:

By Default Tomcat listens in the 8080 port (localhost:8080). It can be changed by changing values in the

$catalina_home\conf\server.xml

Change the value of Connector port to desired port.

THE PART THAT NEEDS TO BE CHANGED IN SERVER.XML

Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true"

Restart Tomcat to see the changes.


Enabling Tomcat for SSI (Server Side Includes)

Rename $CATALINA_HOME/server/lib/servlets-ssi.renametojar to $CATALINA_HOME/server/lib/servlets-ssi.jar.

Remove the XML comments from around the SSI servlet and servlet-mapping configuration in $CATALINA_BASE/conf/web.xml.

DB2 Catalog Commands

Tomcat may have to be restarted if you re-catalog an existing database that is being used in your code.

Errors

Looking at the Tomcat log files will help you solve the error messages that you see on browser.

Location of log files $Catalina_home\logs


Resources:

http://jakarta.apache.org/tomcat/

Monday, November 15, 2004

PreCompiling and Running Embeded SQL

Write your Embeded SQL C code with a file extension .sqc

Precompiling

db2 connect to database name
db2 prep filename.sqc
db2 connect reset

The Above Command on Sucess will give a filename.c file.

The C File needs to compilied with special flags as follows

gcc filename.c -Wall -I/home/db2inst1/sqllib/include/ -L/home/db2inst1/sqllib/lib -ldb2 -Wl,-rpath,/opt/IBM/db2/V8.1/lib -o

Run the outputfile to see the results.


NOTE:
  • The flags may vary if you have a username other than db2inst1.
  • And the flags need to be properly spaced.