Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tomcat 4.0 DataSource No suitable driver

20 views
Skip to first unread message

Vance Christiaanse

unread,
Aug 28, 2002, 2:15:42 PM8/28/02
to
Hello, DB2 fans,

I am using Tomcat 4.0.4 and can't get a DataSource working
with DB2.

My attempts result in "No suitable driver", as detailed below.

I have tried everything I've seen suggested for
this problem, as the following steps indicate.

Any help would be much appreciated.

Thank you in advance,

Vance Christiaanse

============================================

1. Applied FixPack 7 (the latest fixpack) to DB2 7.2

2. Successfully ran usejava2 (to convert DB2 to use JDBC 2.0)

3. Added db2java.zip to catalina classpath by editing
bin\setclasspath.bat

4. Added copy of db2java.zip, renamed with .jar extension,
to appropriate WEB-INF\lib

5. Updated appropriate conf\server.xml Context element to
include

<Resource name="jdbc/Alpha" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/Alpha">
<parameter>
<name>driverClassName</name>
<value>COM.ibm.db2.jdbc.app.DB2Driver</value>
</parameter>
<parameter>
<name>driverName</name>
<value>jdbc:db2:MYDB</value>
</parameter>
<parameter>
<name>user</name>
<value>USERID</value>
</parameter>
<parameter>
<name>password</name>
<value>PASSWORD</value>
</parameter>
</ResourceParams>

6. Updated appropriate web.xml to include

<resource-ref>
<res-ref-name>jdbc/WhitePages</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

7. Visited servlet with the following code:

javax.sql.DataSource ds = (javax.sql.DataSource)
ctx.lookup("java:comp/env/jdbc/Alpha");
pw.println("Get here");
conn = ds.getConnection();
pw.println("Don't get here");

8. Got

Get here
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:243)
at
tyrex.jdbc.xa.EnabledDataSource.getConnection(EnabledDataSource.java:233)
at
tyrex.jdbc.xa.EnabledDataSource.getConnection(EnabledDataSource.java:204)


Franco Lombardo

unread,
Aug 29, 2002, 2:35:23 AM8/29/02
to
> <parameter>
> <name>driverClassName</name>
> <value>COM.ibm.db2.jdbc.app.DB2Driver</value>
> </parameter>
> <parameter>
> <name>driverName</name>
> <value>jdbc:db2:MYDB</value>

Maybe you are using the wrong JDBC driver. As explained me Dirk Wollscheid
(by the way, thanks a lot Dirk) in a previous post, there are two JDBC
drivers.
COM.ibm.db2.jdbc.app.DB2Driver is a type 2 driver, that is it works
using some ODBC windows dll, while COM.ibm.db2.jdbc.net.DB2Driver
is a type 3 driver, that is it works using only Java resources to connect
to a middleware software on DB2.
(See
http://www-3.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/document
.d2w/report?last_page=list.d2w&fn=1005576 and
http://java.sun.com/products/jdbc/overview.html)

So try this:

<parameter>
<name>driverClassName</name>
<value>COM.ibm.db2.jdbc.net.DB2Driver</value>


</parameter>
<parameter>
<name>driverName</name>

<value>jdbc:db2://servername_or_address/MYDB</value>


Bye

Franco


Vance Christiaanse

unread,
Aug 29, 2002, 7:37:44 AM8/29/02
to
Franko,

I just tried the net driver without success but thank you!

I've set up DB2 DataSources with both WebSphere and WebLogic using the app
driver. It should be possible to do it with Tomcat as well.

Still working on it,

Vance

"Franco Lombardo" <f_lom...@hotmali.com> wrote in message
news:akkfa9$1ijns3$1...@ID-100339.news.dfncis.de...

Vance Christiaanse

unread,
Aug 29, 2002, 6:35:56 PM8/29/02
to
DB2 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


Franco Lombardo

unread,
Aug 30, 2002, 3:08:24 AM8/30/02
to

"Vance Christiaanse" <cin...@twcny.rr.com> ha scritto nel messaggio
news:cInb9.153348$vg.25...@twister.nyroc.rr.com...

> Franko,
>
> I just tried the net driver without success but thank you!
>

Was the DB2JD (DB2 Java deamon) running on the DB2 server?

Bye

Franco


Dirk Wollscheid

unread,
Aug 29, 2002, 12:08:15 PM8/29/02
to
Vance Christiaanse wrote:
> Franko,
>
> I just tried the net driver without success but thank you!


It should work with both drivers.

I wanted to try that yesterday, but I don't have enough information for
the setup.

E.g. What class would one use as an initialContextFactory to get to the
JNDI server to find the datasource?

It would be great if you can also send me your full servlet (or an
example) and all the setup info and I will try it sometime (probably not
this week)

Regards, Dirk

--
-------------- This is not an IBM official response --------------

All the information and opinions expressed herein are those of the
author and are not an official IBM statement.

It's also not OK to contact the author with questions using his
email adress.

oool

unread,
Sep 29, 2002, 11:03:48 PM9/29/02
to

dear dbgurus,
please give me solution soon
here iam using simple servlet application
to get connection from (tomcat4.0.4 tyrex) connection pool
using datasource using thin driver for the oracle database.
Do i need to set anything in the classpath of setclasspath.bat
in tomcat/bin...???? if so, please send me the code exactly
because iam so week in setting them.

my previous connection using DriverManager was:

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con=DriverManager.getConnection("jdbc:oracle:thin:@oracle:1521:ORCL","m-
ail","mail");

now i used connection using DataSource.

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/EmpDB");
Connection conn = ds.getConnection();

1. my servlet class file was in
tomcat\webapps\root\web-inf\classes
2. my thindriver's classes12.jar was in
tomcat\common\lib
(i renamed classes12.zip to classes12.jar)

I dont know exactly which <context> should be commented
and which one uncommented in server.xml file, infact
iam unfamiliar with xml configurations.
so if possible correct my server.xml and send me.
here is my server.xml,web.xml for ur reference.

my server.xml content is:
-------------------------


<Server port="8005" shutdown="SHUTDOWN" debug="0">

<Service name="Tomcat-Standalone">

<Connector
className="org.apache.catalina.connector.http.HttpConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="60000"/>

<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>

<Engine name="Standalone" defaultHost="localhost" debug="0">

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>


<Realm className="org.apache.catalina.realm.MemoryRealm" />


<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true">

<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common"/>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>

<!-- Tomcat Root Context -->


<Context path="" docBase="ROOT" debug="0">

<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxx -->
<Resource name="jdbc/EmpDB" auth="SERVLET" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/EmpDB">
<parameter>
<name>user</name><value>mail</value>
</parameter>
<parameter>
<name>password</name><value>mail</value>
</parameter>
<parameter>
<name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</val-
ue>
</parameter>
<parameter>
<name>url</name><value>jdbc:oracle:thin:@oracle:1521/ORCL</value>
</parameter>

<parameter><name>maxActive</name><value>32</value></parameter>
<parameter><name>maxIdle</name><value>10</value></parameter>

</ResourceParams>

<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxx -->


<!-- Tomcat Manager Context -->

<!-- <Context path="/manager" docBase="manager" debug="0"
privileged="true"/> -->

<!-- Tomcat Examples Context

<Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true">

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_examples_log." suffix=".txt"
timestamp="true"/>
<Ejb name="ejb/EmplRecord" type="Entity"
home="com.wombat.empl.EmployeeRecordHome"
remote="com.wombat.empl.EmployeeRecord"/>
<Environment name="maxExemptions" type="java.lang.Integer"
value="15"/>
<Parameter name="context.param.name"
value="context.param.value"
override="false"/>


<Resource name="mail/Session" auth="Container"
type="javax.mail.Session"/>

<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
<value>localhost</value>
</parameter>
</ResourceParams>
-->

</Context>
</Host>

</Engine>

</Service>

<!-- Define an Apache-Connector Service -->
<Service name="Tomcat-Apache">

<Connector
className="org.apache.catalina.connector.warp.WarpConnector"
port="8008" minProcessors="5" maxProcessors="75"
enableLookups="true" appBase="webapps"
acceptCount="10" debug="0"/>

<!-- Replace "localhost" with what your Apache "ServerName" is set
to -->
<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache" debug="0">

<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>

<!-- Because this Realm is here, an instance will be shared
globally -->
<Realm className="org.apache.catalina.realm.MemoryRealm" />
</Engine>
</Service>
</Server>


my web.xml is:
--------------

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<servlet>
<servlet-name>DataSourceServlet</servlet-name>
<servlet-class>DataSourceServlet</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>DataSourceServlet</servlet-name>
<url-pattern> /DataSourceServlet </url-pattern>
</servlet-mapping>

<resource-ref>
<description> Resource reference to a factory for java.sql.Connection
instances that may be used for talking to a particular
database that is configured in the server.xml file.
</description>
<res-ref-name>jdbc/EmpDB</res-ref-name>


<res-type>javax.sql.DataSource</res-type>
<res-auth> Container</res-auth>
</resource-ref>

</web-app>


The Exception iam getting when i run the application
as "http://localhost:8080/DataSourceServlet"
is:

java.sql.SQLException: No suitable driver

--
Posted via http://dbforums.com

0 new messages