| Author |
Tomcat and Oracle, will i transfer any file?
|
Ola Kesh
Ranch Hand
Joined: Dec 24, 2002
Posts: 40
|
|
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?
|
 |
Dave Salter
Ranch Hand
Joined: Jul 20, 2005
Posts: 292
|
|
|
You need to move the Oracle ODBC classes driver into Tomcat or into you web apps WEB-INF/lib directory.
|
 |
Ola Kesh
Ranch Hand
Joined: Dec 24, 2002
Posts: 40
|
|
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.
|
 |
ramprasad madathil
Ranch Hand
Joined: Jan 24, 2005
Posts: 489
|
|
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
Joined: Dec 24, 2002
Posts: 40
|
|
|
pls were are the jar files located?
|
 |
Zaheer Nanji
Greenhorn
Joined: Jul 05, 2005
Posts: 5
|
|
|
The jar files should be present in ORACLE_HOME\jdbc\lib directory
|
 |
ramprasad madathil
Ranch Hand
Joined: Jan 24, 2005
Posts: 489
|
|
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.
|
 |
sweta naidu
Greenhorn
Joined: Nov 02, 2004
Posts: 25
|
|
|
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
Joined: Jan 24, 2005
Posts: 489
|
|
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
Joined: Dec 24, 2002
Posts: 40
|
|
Hello friends, i have done all these, yet i still have the same error
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
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.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
ramprasad madathil
Ranch Hand
Joined: Jan 24, 2005
Posts: 489
|
|
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
Joined: Dec 24, 2002
Posts: 40
|
|
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!
|
 |
 |
|
|
subject: Tomcat and Oracle, will i transfer any file?
|
|
|