• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat and Oracle, will i transfer any file?

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
i have a JSP code that is not connecting to an oracle 10g database.
Am running on tomcat and it always return this error: "can't load driver".

this is my driver code:

//Load the driver class file
Class.forName("oracle.jdbc.driver.OracleDriver");

// Make a connection to the data source "Airline" with no user name and password
String url ="jdbc racle:thin:@localhost:1521:Airline";
con = DriverManager.getConnection(url,"kesh","kesh");


Am i suppose to move any file from oracle to my tomcat?
 
Ranch Hand
Posts: 293
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to move the Oracle ODBC classes driver into Tomcat or into you web apps WEB-INF/lib directory.
 
Ola Kesh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dave,
I cpoied the ODBC directory, located in "C:\oracle\product\10.1.0\db_1" into "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\jsp-examples\WEB-INF\lib" but it still gives the same error of can't load driver.
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I cpoied the ODBC directory



Copying the directory will not help.
You will have to copy the jars that contain the driver and associated classes.

cheers,
ram.
 
Ola Kesh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
pls were are the jar files located?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The jar files should be present in ORACLE_HOME\jdbc\lib directory
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The jar files should be present in ORACLE_HOME\jdbc\lib directory



Um, well, I dont know about Oracle 10, but in 9i, its in
oracle_home\ora92\jdbc\lib and the jar file is either Classes12.jar or Classes111.jar depending on the driver version you require.

I would suggest that you explore in the Oracle installation directory, search for folders like jdbc/lib and once you find the jars, double click and open with winzip and examine the classnames for OracleDriver.class

cheers,
ram.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you need to place Classes12.jar or Classes111.jar files in tomcat\common\lib directory and you can download these jar files from oracle website.i think they are available in zip format but you have to rename them as jar.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


originally posted by Sweta

you need to place Classes12.jar or Classes111.jar files in tomcat\common\lib directory



IMO, you would be better off placing the jars in <YOUR_WEBAPP>/WEB-INF/lib/ directory.

cheers,
ram.
 
Ola Kesh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,
i have done all these, yet i still have the same error
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ramprasad madathil:


IMO, you would be better off placing the jars in <YOUR_WEBAPP>/WEB-INF/lib/ directory.

cheers,
ram.



I agree, unless your using a container managed connection pool.
If you are then the container needs access to the drivers.
In that case tomcat/common/lib is the place to put it.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


originally posted by Ben Souther

I agree, unless your using a container managed connection pool.
If you are then the container needs access to the drivers.
In that case tomcat/common/lib is the place to put it.



Correct. And that's because Tomcat uses Jakarta Commons DBCP libraries to instantiate the JDBC Driver class and the Tomcat Classloader hierarchy won't find the driver file unless it's loaded by the same classloader.

However, there is a workaround (& this came up on a discussion on self contained wars..)- if commons-pool-1.2.jar and commons-dbcp-1.2.1.jar are copied into WEB-INF/lib from common/lib (perhaps during an ant build), then
these libraries are picked before the ones in /common/lib and the drivers would be loaded properly.

cheers,
ram.
 
Ola Kesh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Now am more confused, i did all you said and it still gave the same error and suddenly, it stops given the error.
Now i really dont know what solved the problem.
pls someone explain to me!
 
reply
    Bookmark Topic Watch Topic
  • New Topic