aspose file tools*
The moose likes JDBC 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
Bookmark "Problems Verifying Oracle Drivers" Watch "Problems Verifying Oracle Drivers" New topic
Author

Problems Verifying Oracle Drivers

Mike Cutter
Ranch Hand

Joined: Jun 09, 2002
Posts: 49
I am using HP-UX 11.11, Java2 1.4.2.04, and Oracle 9.2.0.5. 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",
"oracle.jdbc.OracleDriver"};
Properties prop = new Properties();
try {
for (int i=0; i<driverClasses.length; i++) {
Class.forName(driverClasses[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: " +
driver.getClass().getName());
System.out.println(" JDBC Compliant: " +
driver.jdbcCompliant());
}
} catch (Exception e) {
System.out.println("OOPS! "+e.toString());
System.exit(0);
}
}
}

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

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.

Mike
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 VerifyDrivers.java

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 VerifyDrivers.java 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.
Why?
Because classpath lacks the current directory:


http://home.arcor.de/hirnstrom/bewerbung
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: http://aspose.com/file-tools
 
subject: Problems Verifying Oracle Drivers