First, install DataDirect Connect for JDBC using the instructions in the DataDirect Connect for JDBC Installation Guide.
Next, copy the DataDirect Connect for JDBC jar files (util.jar, base.jar, db2.jar, informix.jar, oracle.jar, sqlserver.jar, and sybase.jar) from:
install_dir/lib
to:
CATALINA_home/common/lib
where install_dir is your DataDirect Connect for JDBC installation directory and CATALINA_home is your Tomcat installation directory.
If you plan to use DataDirect Spy, you must also copy spy.jar from the install_dir/spy subdirectory of your DataDirect Connect for JDBC installation directory to CATALINA_home/common/lib.
To use the Tomcat Administration and Management tools, you must create a user with "admin" and "manager" roles. To do this, follow these steps:
<
role
rolename
=
"manager"
/>
<
role
rolename
=
"admin"
/>
<
user
username
=
"admin"
password
=
"myAdminPwd"
fullName
=
"Administrator"
roles
=
"admin,manager"
/>
To create a data source using the Tomcat Administration tool:
You must create a JSP page that uses a data source. A sample JSP test page named TomcatTest.jsp is contained in the TomcatTest.war file, which is available with this document. The TomcatTest.jsp page includes the following code to look up the data source and obtain a connection to the database from the data source.
InitialContext ctxt = new InitialContext ();
DataSource ds = (DataSource)
ctxt.lookup("java:/comp/env/ds/TestDS");
Con = ds.getConnection ();
Copy the TomcatTest.war file, available with this document, to the directory CATALINA_home/webapps.
When you created the data source in Step 3, it was created in the global name space. The data source is not visible to the TomcatTest web application. To access the data source from within the TomcatTest web application, you must create a link to the global data source in the TomcatTest context. To do this, follow these steps:
<
Context
className
=
"org.apache.catalina.core.StandardContext"
cachingAllowed
=
"true"
charsetMapperClass
=
"org.apache.catalina.util.CharsetMapper"
cookies
=
"true"
crossContext
=
"false"
debug
=
"0"
displayName
=
"TomcatTest"
docBase="C:\Products\Tomcat
\jakarta-tomcat-4.1.29\webapps\TomcatTest.war"
mapperClass
=
"org.apache.catalina.core.StandardContextMapper"
path
=
"/TomcatTest"
privileged
=
"false"
reloadable
=
"false"
swallowOutput
=
"false"
useNaming
=
"true"
wrapperClass
=
"org.apache.catalina.core.StandardWrapper"
>
<
ResourceLink
global
=
"jdbc/TestDS"
name
=
"ds/TestDS"
type
=
"javax.sql.DataSource"
/>
</
Context
>
http://localhost:8080/TomcatTest
1 The steps in this paper were generated using Tomcat version 4.1.29. These steps may vary for other versions of Tomcat.