Accessing external jar from servlet
From: Larry Coon (lmcoon_at_nospam_cox.net)
Date: 12/28/04
- Previous message: Ryan Stewart: "Re: Error: orphaned case"
- Next in thread: Java Lover: "Re: Accessing external jar from servlet"
- Reply: Java Lover: "Re: Accessing external jar from servlet"
- Reply: Juha Laiho: "Re: Accessing external jar from servlet"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 27 Dec 2004 22:08:54 -0800
I'm trying to learn servlets, and am stuck getting the servlet
to use JDBC (specifically, Sybase's JConnect), which I think is
due to my not understanding how to provide the servlet with
access to the JDBC's jar file. I'd like to provide a small,
self-contained example, but I'm not sure that's possible here,
so let me just describe what I'm trying to do.
First, note the following:
-- I can get basic servlets running (with Tomcat) just fine.
-- I can use JDBC just fine with my Java applications.
Where I'm stumped is with this concept: My jdbc classes are in
C:\Java\jConnect-5_5\classes\jconn2.jar
>From an _application_ I just import the right classes:
import com.sybase.jdbc2.jdbc.*;
and do the usual Class.forName to load the driver:
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
and then I can tell the jvm where the jar file is:
java -cp .;C:\Java\jConnect-5_5\classes\jconn2.jar mypackage.MyApp
and all is well. But with a servlet, how do I provide that
connection between the Java code and the jar file? When I invoke
my servlet, Tomcat's log contains the following:
java.lang.ClassNotFoundException: com.sybase.jdbc2.jdbc.SybDriver
(followed by a full stack trace) afterward. The stack trace
indicates it choked during the Class.forName(), i.e., when trying
to load the driver.
The obvious thing (to me) seemed to be the CLASSPATH env variable,
but pointing CLASSPATH to the jar file didn't make any difference.
I tried checking all the docs I could find, but didn't find anything
that helped me (which I assume is a case of information overload on
my part rather than the information not being out there). Any
pointers would be appreciated.
Thanks.
- Previous message: Ryan Stewart: "Re: Error: orphaned case"
- Next in thread: Java Lover: "Re: Accessing external jar from servlet"
- Reply: Java Lover: "Re: Accessing external jar from servlet"
- Reply: Juha Laiho: "Re: Accessing external jar from servlet"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|