IDependOn-Set: 1
IDependOn-Set: 119
IDependOn-Set: 2
IDependOn-Set: 212
IDependOn-Set: 214
IDependOn-Set: 228
LastModifiedSecs: 939422662
Parent: 119
SequenceNumber: 7
Title: Why do I get a ClassNotFoundException on my JDBC driver?
Part: 0
Author-Set: cmcclanahan@mytownnet.com
LastModifiedSecs: 929036129
Type: monospaced
Lines: 49
I'm not sure who to send this too, but I've read much
documentation and I can't figure out why I can't get a jdbc
driver or two to work in my servlets


The first few lines of service
are

    public void service (
        HttpServletRequest      request,
        HttpServletResponse     response
    ) throws ServletException, IOException
    {
        PrintWriter             out;
        String                  title = "Simple Servlet Output";
        
        String dead = "default";

        try { 
                Class.forName("org.gjt.mm.mysql.Driver"); 
                Connection con =
DriverManager.getConnection("jdbc:mysql://db.domain.com:3306/AMR?user=root&password=");
                System.out.println("Connected to the db");
                dead = "but I'm not dead yet";
        }
        catch (ClassNotFoundException e) { 
                System.out.println("Couldn't find class: " +
e.getMessage()); 
                dead = "died- ClassNotFoundException";

        }
        catch (SQLException se){ 
                System.out.println("SQL Exception caught: " + se); 
                dead = "died- SQLException";
        } 



If I print dead it is always "died-ClassNotFoundException, 
yet if I
do
import org.gjt.mm.mysql.Driver

and verbose on compile I get this:
why won't forName find it?

[loaded
c:\java\mm.mysql.jdbc-1.2a\mysql.jar(org/gjt/mm/mysql/Driver.class) in 94
ms]
EndPart: 0
Part: 1
Author-Set: cmcclanahan@mytownnet.com
LastModifiedSecs: 929036440
Type: monospaced
Lines: 31
Your compile works because you have correctly added the MySQL driver's
JAR file to your system CLASSPATH.  However, Apache JServ does not use this
CLASSPATH when it starts up.  You must define the class path you want in the
configuration files.  There are two places you can do this (the first one is
the better choice for a database driver):

(a) SYSTEM CLASSPATH

In the "jserv.properties" file, you can add entries like this to add things
to the system CLASSPATH that is used by Apache JServ and the servlets you run:

wrapper.classpath=/java/mm.mysql.jdbc-1.2a/mysql.jar

This will cause the driver to get loaded from the system class path, just like
it does for the compiler.  However, any classes loaded from here cannot be
reloaded if you recompile them.

(b) ZONE CLASSPATH

If you want to take advantage of the automatic reloading feature (good for
servlets, but not really useful in the particular case of a JDBC driver), add
a line like this to your "zone.properties" file:

repositories=/my/path/to/myservlets

and the servlets in the "myservlets" directory will be reloaded when you change
them (assuming you have configured the autoreload feature on -- see the
configuration file documentation).



EndPart: 1
Part: 2
Author-Set: jon@working-dogs.com
HideAttributions: 1
LastModifiedSecs: 934389774
Type: monospaced
Lines: 3
On Unix, set the LD_LIBRARY_PATH to your dynamic (ie: .so) files correctly.

On NT, set the java.library.path System property variable to the .dll files correctly.
EndPart: 2
Part: 3
Author-Set: jean_tremblay@dialog.com
LastModifiedSecs: 938507319
Type: monospaced
Lines: 18
I have installed successfully Apache 1.3.9 and JServ 1.0.
I am using:
 - Apache 1.3.9 on SunOS 5.7
 - JServ 1.0
 - Oracle JDBC-thin driver V8.1.6

I have tried many things but I always get:
[24/09/1999 15:11:36:545] (ERROR) ajp11: Servlet Error: Initialization error whi
le loading the servlet: ClassNotFoundException: oracle.jdbc.driver.OracleDriver!!

I have tried setting in jserv.properties : 
wrapper.classpath=/opt/app/oracle/product/8.1.6/jdbc/lib/nlscharset12.zip
wrapper.classpath=/opt/app/oracle/product/8.1.6/jdbc/lib/classes12.zip

I have tried setting CLASSPATH.
I have tried creating a zone which points on my classes. Nothing worked! :(

I know that my servlet is working, I made it work with JSDK.
EndPart: 3
Part: 4
Author-Set: jean_tremblay@dialog.com
LastModifiedSecs: 938513198
Type: monospaced
Lines: 1
Can anyone help me?
EndPart: 4
Part: 5
Author-Set: acruise@globalmedia.com
LastModifiedSecs: 939422662
Type: html
Lines: 3
Actually, none of the suggestions on this page solved my problem.  
<a href="http://java.apache.org/faq/fom-serve/cache/261.html">This one,</a> 
however, did.
EndPart: 5
