Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

oracle.jdbc.driver.OracleDriver not found

843859Oct 26 2007 — edited Oct 29 2007
I have a program which connects to a Oracle Database through JDBC on Ubuntu 7.04 Feisty Fawn; well, it's still trying to do it. The Oracle's release is 10g, so I'm using "ojdbc14.jar" file to connect to it. This jar file is included correctly in the classpath environment variable.

The error message is the next one:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
java.sql.SQLException: No driver found for jdbc:oracle:thin:@10.111.9.5:1522:DBDMR10

Please, answer as soon as possible, any suggestion is welcomed.

Thanks

Comments

796254
siyi23 wrote:
I have a program which connects to a Oracle Database through JDBC on Ubuntu 7.04 Feisty Fawn; well, it's still trying to do it. The Oracle's release is 10g, so I'm using "ojdbc14.jar" file to connect to it. This jar file is included correctly in the classpath environment variable.
No, it's not. That's what CNF exception is telling you.

Java ignores CLASSPATH environment variable. The right way to add a 3rd party JAR is to use the -classpath option on javac.exe and java.exe.

%
843859
I've been testing several possibilities and I've realized I've forgotten a detail: I'm trying to execute a program compressed in a jar file. When I run the connection-part of my code with the main class it doesn't fail, but when I do with the jar file it cannot find the driver class.

The connection-part of my code is:
//////////////////////////////////////////////////////////////////
import java.sql.Driver;
public class prueba {
static String DB_DRIVER = "oracle.jdbc.driver.OracleDriver";
public static void main(String [] args) {
try {
final Driver driver = (Driver) Class.forName(DB_DRIVER).newInstance();
System.out.println("Todo bien");
} catch (final Exception e) {
System.out.println("Se produjo un error al cargar el driver ["
+ DB_DRIVER + "] de la base de datos.");
System.out.println(e.toString() + "\r\n");
}
}
}
//////////////////////////////////////////////////////////////////

And the prompts I'm running are (Windows version):
java -classpath .;"E:\ojdbc14.jar" -jar prueba.jar
java -classpath .;"E:\ojdbc14.jar" prueba

The first one runs correctly, but the last one doesn't. What is the problem?
843859
I've found the solution in other posts. My problem was that I was trying to specify an extra classpath for a jar execution, but jar executions don't recognise any extra classpaths, neither in the environment variable nor the same command-line. The solution is to copy the files needed to include in the classpath to the jre\lib\ext subdirectory from the jdk directory.
1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 26 2007
Added on Oct 26 2007
3 comments
1,769 views