Vance,

I did a little more digging and discovered that the JSP snippet I sent 
previously works using Class.forName() for both app and net drivers, but 
curiously enough Class.forName().newInstance() throws an SQLException 
when using the app driver, but not the net driver.

Using the app driver, our webapp throws the same SQLException (CLI0647E 
Error allocating DB2 environment handle, rc=-1) as the JSP snippet. So I 
took a peek at the Struts 1.0.2 GenericDataSource code, where the "Root 
Cause" SQLException originated and sure enough, there is a newInstance() 
call on the Driver. I'm not sure exactly what it means, and doubt it's 
even relevant to your situation, but it's interesting to note that two 
different implementations of DataSource appear to be failing in 
different ways (or perhaps we both doing something wrong!) using the app 
driver.

Concerning your question about what's more appropriate -- app or net 
driver?
According to IBM, for raw performance, the app driver is the one to use: 
http://www-1.ibm.com/support/docview.wss?rs=71&q=COM.ibm.db2.jdbc.net&uid=
swg21005576

Also, I don't think it's an XP issue, because we've not been able to get 
the app driver working on Linux either, except for explicit 
Class.forName() calls, which is why I suggested the net driver.

To me the upside of the net driver is two-fold:
1) it's more flexible -- allowing both local and remote connections (we 
actually need to do both)
2) we can actually get it to work via DataSource for local connections

I'm not a DB2 guru by any means and have never used the JNDI stuff in 
Tomcat, but I still suggest trying the net driver for 4.0.x, just to see 
if if works. We're  satisfied with it's performance, you might be too.

Of course, if you've got it working with 4.1.x, why don't you go ahead 
and use it?

Rick

On Friday, August 30, 2002, at 05:58 PM, Vance Christiaanse wrote:

> 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: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