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","password"
);
        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]>

Reply via email to