jdbc driver test
Hello
I have some code here to test a jdbc driver. Unfortionally I get a
NoClassDefFoundError. Here my code:
import java.sql.*;
import java.util.*;
public class DriverTest{
public DriverTest(String driverClazz)
throws ClassNotFoundException, SQLException {
Class.forName(driverClazz);
}
public void info() throws SQLException {
Enumeration e = DriverManager.getDrivers();
System.out.println("Available drivers: ");
while (e.hasMoreElements()) {
Driver driver = (Driver) e.nextElement();
System.out.println("Driver: " + driver.getClass().getName());
System.out.println("Major version: " + driver.getMajorVersion());
System.out.println("Minor version: " + driver.getMinorVersion());
System.out.println("JDBC compliant: " + driver.jdbcCompliant());
}
}
public static void main( String args[] ) throws Exception{
if (args.length != 1) {
System.out.println("usage: java DriverTest <DriverClazz>");
}else{
DriverTest dt = new DriverTest(args[0]);
dt.info();
}
}
}
This is what I do at shell (one line):
/usr/local/jdk1.6.0/bin/java -cp /path/to/postgersql-8.2-504.jdbc4.jar
DriverTest org.postgresql.Driver
I've tested this code a while ago on a Windows machine and with an oracle
driver, that worked fine. Hope somenone can help.
Thx