Rick,
I tried the following (all with db2java.zip renamed to db2java.jar and
located in lib\common):
WORKED: The Class.forName code using the DB2 app driver with Tomcat 4.0.4
FAILED: DataSource using the DB2 app driver with Tomcat 4.0.4
WORKED: DataSource using the Cloudscape driver with Tomcat 4.0.4
WORKED: DataSource using the DB2 app driver with Tomcat 4.1.9 (and 4.1.10)
I certainly could have made some error in my testing. But I still haven't
heard anyone say they are successfully using the DB2 app driver to implement
a DataSource with Tomcat 4.0.4. It works just fine with 4.1.x.
I'm doing all this on XP; I wonder if that's a factor.
If DB2 is running on the same machine as Tomcat, wouldn't the app driver be
more appropriate--and faster? I don't know for sure but I would guess there
is more overhead with the net driver than the app driver when the access is
local. (When the access is non-local I realize the net driver is necessary.)
Vance
----- Original Message -----
From: "Rick Yoesting" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Friday, August 30, 2002 4:44 PM
Subject: Re: DB2 DataSources and Tomcat 4.0.4
> Vance,
>
> We're using DB2 via DataSource with Tomcat 4.0.3 using Struts
> (<data-source> element in struts-config.xml), so I assume this means it
> should work without Struts also. Below is a JSP snippet that should tell
> you if you're driver is working or not outside of Tomcat's Resource
> Factory.
>
> From what I gathered in your previous posts, you're using
> COM.ibm.db2.jdbc.app.DB2Driver. I think you should be using
> COM.ibm.db2.jdbc.net.DB2Driver.
>
> As for where to put the driver -- we renamed the .zip file to .jar and
> put it in <CATALINA_HOME>/common/lib.
>
> One last thought -- make sure DB2's JDBC Applet Server/Listener is
> running.
>
> Good luck,
>
> Rick
>
> <%@ page language="java" import="java.util.*,java.sql.*" %>
> <%
> try {
> Class.forName("COM.ibm.db2.jdbc.net.DB2Driver").newInstance();
>
>
DriverManager.getConnection("jdbc:db2://localhost/dbAlias","username","passw
ord"
> );
> Statement stmt = conn.createStatement();
>
> ResultSet rs = stmt.executeQuery("select * from sometable");
>
> while (rs.next()) {
> // do something
> }
> rs.close();
> stmt.close();
> conn.close();
>
> } catch (SQLException sqle) {
> // handle SQLException
> } catch (Exception e) {
> // handle exception
> }
> %>
>
> On Thursday, August 29, 2002, at 05:34 PM, Vance Christiaanse wrote:
>
> > Tomcat fans,
> >
> > I've been trying to configure a DataSource in Tomcat 4.0.4 to use DB2
> > for...
> > well, for longer than I'd like to admit. I've searched the web and
> > experimented with jars vs. zips, with renaming them vs. rebuilding them,
> > with the lib folder vs. the common\lib folder, with "url" vs.
> > "driverName",
> > and so on.
> >
> > As a sanity check, I just tried switching my server.xml driverClassName
> > and
> > driverName to values appropriate for Cloudscape and put the requisite
> > jar
> > files in common\lib. The DataSource in my servlet worked fine the first
> > time! (And for the first time ever!)
> >
> > I believe there is an issue with the DB2 driver involving native
> > libraries
> > and classloaders. I suspect that Tomcat works just fine with drivers
> > (e.g.
> > Cloudscape) that don't use native libraries.
> >
> > I'm sending this because I hope it
> > (1) helps others who are trying to get DB2 working via a DataSource in
> > Tomcat
> > (2) inspires those who know more about this to tell us about it--
> > In particular, has *anyone* *ever* gotten this to work?
> >
> > Vance
> >
> >
> > --
> > To unsubscribe, e-mail: <mailto:tomcat-user-
> > [EMAIL PROTECTED]>
> > For additional commands, e-mail: <mailto:tomcat-user-
> > [EMAIL PROTECTED]>
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>