Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JDBC

Status
Not open for further replies.

pisth

Programmer
Mar 18, 2003
43
US
Hell0,
I have a JSP application and Tomcat is used as the web server. When i try to run the program, i get an error which gets displayedin the web server....which says:

java.lang.ClassNotFoundException:eek:racle.jdbc.driver.OracleDriver

When I compile the program i get the following error.(it is a very simple program).

package oracle.jdbc.driver does not exist
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver ());

code looks something like this...

private void outputF() throws SQLException {
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver ());
} catch (Exception e) {
System.out.println(e.toString());
}
Connection conn = DriverManager.getConnection ("jdbc:eek:racle:karthik:mad:xyz.itt.com:1521:db01", "info", "OraD");

WHat am i supposed to do?. i.e how do i estabilish the connectivity between Java and Oracle?. do i need to install something?. if so what?...

Please suggest.

Thanks!

Regards,
Karthik.


 
>> do i need to install something?. if so what?...

Yes. The class that is reportedly not found [red]oracle.jdbc.driver.OracleDriver[/red]

You get the Oracle driver from Oracle.

-pete
 
Hell0,
I installed something called OracleClient(C:\oracleclient\92010NT_CLT)

and also ran the setup. i gave the name of the driver etc when i ran the set up. however when i compile the program...i still get the error?. do i set the classpath or something?. whatz wrong?. can you give me a few steps and a sample peice of code to set up classpath plz.

Thanks!

Regards,
Karthik.
 
get the oracle driver jar file(that has the driver) and place it under your tomcat \common\lib directory. This is assuming you have multiple apps that will use the same driver.

go to apache.org for more info. You have to setup server.xml and web.xml if you want to set up the property for that driver.


~za~
You can't bring back a dead thread!
 
are you trying to run a java program or are you trying to connect to JDBC through tomcat - for your jsp app? They're 2 different things.

~za~
You can't bring back a dead thread!
 
Hell0,
Now when i set the classpath...as suggested by you people...i set the classpath for classes12.zip. and now i am able to compile the program without any errors.

When i restart the tomcat server and run the program, on the tomcat window, i still get an error which says:

java.lang.ClassNotFound Exception:eek:racle.jdbc.driver.OracleDriver.

and it also takes me to a page which gives out a lot of errors...HTTP Status 500: Exception...RootCause etc.

well...i have a jsp page,,,and that inturn calls the java program and this setup runs on a tomcat server.
hope i am clear.

Thanks!

Regards,
Karthik.
 
when you set the classpath, you allow the java program to run. However, if you have a web app, you have to set up your tomcat web server correctly.

check out the link to apache provided by pete. To enable the web-application(your jsp to work correctly), that link shows how to set up server.xml, web.xml correctly. Go to that page and there is an example that uses Oracle as the database.

~za~
You can't bring back a dead thread!
 
Hi Karthik,
As you set the classpath to compile the program, you need to set the classpath while running also. So set the classpath to the classes12.zip in the tomcat startup script (I think, it will be <<tomcat-home>>\bin\startup.bat). Hope, this would solve your issue.

Regards,
Shanmy
 
Hell0 Shanmy,
Thanks for your reply.

I included the classes12.zip classpath on my startup.bat. I am using Tomcat 4.1.24 version though...anyways...downloaded the exe file of tomcat and installed it. my startup.bat looks like this now:

@echo off
if &quot;%OS%&quot; == &quot;Windows_NT&quot; setlocal
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat,v 1.4 2002/01/15 02:55:38 patrickl Exp $
rem ---------------------------------------------------------------------------

rem Guess CATALINA_HOME if not defined
if not &quot;%CATALINA_HOME%&quot; == &quot;&quot; goto gotHome
set CATALINA_HOME=.
if exist &quot;%CATALINA_HOME%\bin\catalina.bat&quot; goto okHome
set CATALINA_HOME=..
:gotHome
if exist &quot;%CATALINA_HOME%\bin\catalina.bat&quot; goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:eek:kHome

set CLASSPATH=C:\oracle\ora92\jdbc\lib\classes12.zip;.;

set EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat

rem Check that target executable exists
if exist &quot;%EXECUTABLE%&quot; goto okExec
echo Cannot find %EXECUTABLE%
echo This file is needed to run this program
goto end
:eek:kExec

rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if &quot;&quot;%1&quot;&quot;==&quot;&quot;&quot;&quot; goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

call &quot;%EXECUTABLE%&quot; start %CMD_LINE_ARGS%

:end


However i still get the error when i try executing the jsp application. The error in the Tomcat server window says that:

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

Kindly let me know what i am supposed to do...to get this working.

Thanks!

Regards,
Karthik.
 
you are not setting up your tomcat server correctly. please check my last response. the file classes12.zip has to be copied over to your tomcat \common\lib directory. if your tomcat is on d:\ drive then move classes12.zip to
d:\tomcat41\common\lib folder.


again, pete's link to apache has an example. You have to setup your server.xml and web.xml file correctly and add the jdbc resource to thes xml file.

this is an example from the link suggested using jndi.


ih have a reference book on tomcat 4 written by james goodwill. you may want to consider getting this.

~za~
You can't bring back a dead thread!
 
Hell0 All,
Thanks for all your help...it worked...i had to copy the classes12.jar file into the common/lib directory of tomcat and then i started tomcat again and the program was able to connect to the database. Yeah...your suggestions worked...Thanks!

Regards,
Karthik.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top