File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes First Servlet, Jdbc program :( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "First Servlet, Jdbc program :(" Watch "First Servlet, Jdbc program :(" New topic
Author

First Servlet, Jdbc program :(

Vanitha Sugumaran
Ranch Hand

Joined: Apr 11, 2001
Posts: 356
Hi,
I am trying to write a code that retrieves info from database and show it on the web. I couldn't view it through Tomcat, I don't understand the reason. Can anyone explain it to me?
This is my code:

I am using correct userid and password. I tried a Jdbc program seperately it works fine. But here it throws Exception.
Just couple of lines of the exception.
javax.servlet.ServletException: Cannot allocate servlet instance for path /examples/servlet/ShowEmployees
root cause
java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
Thanks,
Vanitha.

[This message has been edited by Vanitha Sugumaran (edited November 18, 2001).]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
From the exception given it's clear that the oracle drivers aren't on the classpath that Tomcat is using...
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Your stand-alone program will use the System CLASSPATH, and thus find your Oracle drivers.

Tomcat 4.0.x does not use System CLASSPATH, so you must include your Oracle drivers in the library directory <tomcat-home>/common/lib

This makes it available to any application running under Tomcat, or you can alternately place classes.zip (the Oracle drivers) under the <webcontext>/WEB-INF/lib directory of each webapp that needs db connections.

I also seem to recall that Tomcat doesn't like zip'd files, so simply rename classes.zip to classes.jar

Hope that helps.
Vanitha Sugumaran
Ranch Hand

Joined: Apr 11, 2001
Posts: 356
Thanks Kyle and Mike for your replies.
I copied the classes12.zip, modified to jar file, I kept the classes.jar file in <tomcat home>/common/lib --> didn't work same error.
<tomcat home>/server/lib --> didn't work.
I couldn't find lib dir in the webapps/web-inf directory.
I don't know where else should I keep the classes12.jar file, can anyone give some suggestions please?
Thanks.
Vanitha
Vanitha Sugumaran
Ranch Hand

Joined: Apr 11, 2001
Posts: 356
Hi,
I have a seperate Jdbc program in the tomcat directory it is working, if I mix it with servlet then it is not working what might be the problem?
this is my code for jdbc program:

After keeping the classess.zip do we have specify any path name?
I have to finish my class project with in a week, so if anyone can solve my problem that would be great.
Vanitha.
[This message has been edited by Vanitha Sugumaran (edited November 19, 2001).]
Vanitha Sugumaran
Ranch Hand

Joined: Apr 11, 2001
Posts: 356
Do I have to change anything in server.xml?
Vanitha.
James Redpath
Greenhorn

Joined: Aug 02, 2003
Posts: 13
For Oracle JDBC the key for Apache Jakarta Tomcat 5 is to place the classes111.zip file in the subdirectory common/lib with the jar extension. So rename the Oracle file classes111.zip to classes111.jar and copy to <installed directory>/common/lib/classes111.jar. Then stop and restart the server. It should work.
Harsha Huddar
Greenhorn

Joined: Oct 03, 2003
Posts: 23
If you are using JDK 1.4.x you'll need ojdbc.jar(from Oracle) in common\lib
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: First Servlet, Jdbc program :(