File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Problems Verifying Oracle Drivers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problems Verifying Oracle Drivers" Watch "Problems Verifying Oracle Drivers" New topic

Problems Verifying Oracle Drivers

Mike Cutter
Ranch Hand

Joined: Jun 09, 2002
Posts: 49
I am using HP-UX 11.11, Java2, and Oracle I wrote a simple program that will just verify the JDBC drivers that is not working.

import java.sql.*;
import java.util.*;

class VerifyDrivers {
public static void main(String args[]) {
String driverClasses[] = {"sun.jdbc.odbc.JdbcOdbcDriver",
Properties prop = new Properties();
try {
for (int i=0; i<driverClasses.length; i++) {
Enumeration drivers = DriverManager.getDrivers();
System.out.println("Available drivers are:");
while (drivers.hasMoreElements()) {
Driver driver = (Driver) drivers.nextElement();
System.out.println("\n Driver name: " +
System.out.println(" JDBC Compliant: " +
} catch (Exception e) {
System.out.println("OOPS! "+e.toString());

It compiled fine.
javac -classpath $ORACLE_HOME/jdbc/lib/ojdbc14.jar

It would not execute:
java VerifyDrivers
OOPS! java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver

java -classpath $ORACLE_HOME/jdbc/lib/ojdbc14.jar VerifyDrivers
Exception in thread "main" java.lang.NoClassDefFoundError: VerifyDrivers

I would appreciate some help in learning how to verify the Oracle JDBC drivers. I am not even connecting to the database yet. This program successfully ran with just verifying the JDBC-ODBC driver.

Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

You wouldn't want to use the jdbc-odbc-driver!
Concentrate on the jdbc-driver, ojdbc14.jar.

javac -classpath $ORACLE_HOME/jdbc/lib/ojdbc14.jar

You don't need to specify the path to ojdb14.jar while compiling, since the Driver is only mentioned in a String, and needn't be present at compile time.

javac doesn't expect to find something to compile in the classpath, and finds your in the current dir.

java -classpath $ORACLE_HOME/jdbc/lib/ojdbc14.jar VerifyDrivers
Exception in thread "main" java.lang.NoClassDefFoundError: VerifyDrivers

java doesn't find VerifyDrivers - the question whether JdbcOdbc or Ora14 isn't touched at all.
Because classpath lacks the current directory:
Mike Cutter
Ranch Hand

Joined: Jun 09, 2002
Posts: 49
Thank you for your reply.

Adding the ":." to the classpath executed the program.
I agree. Here's the link:
subject: Problems Verifying Oracle Drivers
It's not a secret anymore!