You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Michael H. Wuest" <mw...@iu.net> on 2002/08/07 00:10:19 UTC
Tomcat 4.0.3, Apache 3.20, and UDB (DB2) 7.2 question
Hi everyone,
I have Tomcat 4.0.3 and Apache 3.20 installed on a Linux 2.4 server. On a
second Linux 2.4 server I have UDB WE 7.2 installed. I have no problems with
connection those systems. Since we are planing to develop more
WEB-Applications we are trying to use Connection Pooling to avoid the
overhead of creating, and destroying a connection.
Does any one has experience with a set-up like it?
Here is my server.xml, web.xml, and the call to the datasource:
server.xml
<host ....
.
.
<!--
================================================================= -->
<!-- Define the DB2 Datasource here, to access via JDBC
-->
<!--
================================================================= -->
<Resource name="jdbc/mlsdb" reloadable="true"
auth="Container" type="COM.ibm.db2.jdbc.DB2DataSource"/>
<ResourceParams name="jdbc/sample">
<parameter>
<name>Factory</name>
<value>COM.ibm.db2.jndi.DB2InitialContextFactory</value>
</parameter>
<parameter>
<name>description</name>
<value>DB2 Connection Pool DataSource for SAMPLE</value>
</parameter>
<parameter>
<name>DatabaseName</name>
<value>sample</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>COM.ibm.db2.jdbc.app.DB2Driver</value>
</parameter>
<parameter>
<name>driveName</name>
<value>jdbc:db2:sample</value>
</parameter>
<parameter>
<name>user</name>
<value>tstusr</value>
</parameter>
<parameter>
<name>password</name>
<value>tst532pwd</value>
</parameter>
</ResourceParams>
..
web.xml
<web-app id="sample">
<display-name>sampleApps.com</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- ============================================== -->
<!-- Define Database Datasource -->
<!-- ============================================== -->
<resource-ref>
<description>DB2 Access to SAMPLE Database</description>
<res-ref-name>jdbc/sample</res-ref-name>
<res-type>COM.ibm.db2.jdbc.DB2DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
.
.
====================================================================
here is a sample jsp file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=ISO-8859-1"
import="java.io.*,java.sql.*,javax.sql.*,javax.naming.*,COM.ibm.db2.jdbc.*"
errorPage="errorPage.jsp" isErrorPage="false" session="true"%>
<%
try{
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
if(envCtx == null ) throw new Exception("No Context found ");
DB2DataSource ds = (DB2DataSource)envCtx.lookup("jdbc/sample");
if (ds != null) {
Connection conn = ds.getConnection();
if(conn != null) {
System.out.println("Got Connection " + conn.toString());
Statement stmt = conn.createStatement();
ResultSet rst = stmt.executeQuery("select * from
employees");
if(rst.next()) {
System.out.println("Got " + rst.getString(2) + " and
" + rst.getString(3));
}
conn.close();
}
else {
System.out.println("Connection for Datasource " + ds.toString() + " is
null");
}
}
else {
System.out.println("Datasource is null for Context " + envCtx.toString());
}
}catch(Exception e) {
e.printStackTrace();
}
%>
<HTML>
<HEAD>
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet" type="text/css">
<TITLE>ConText.jsp</TITLE>
</HEAD>
<BODY>
Place ConText.jsp's content here
</BODY>
</HTML>
.
Here is the error I receive:
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>