I'm a little confused. The fololwing code compiles without error:
import java.net.*; import java.sql.*; import java.io.*; import java.util.*; class MakeDB { public static void main (String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // force loading of driver String url = "jdbc:odbc:BIBLIO"; String user = ""; String password = ""; Connection con = DriverManager.getConnection(url,user,password); Statement stmt = con.createStatement(); ResultSet r=stmt.executeQuery("SELECT TITLE,AUTHOR FROM TITLES, AUTHORS WHERE TITLES.AU_ID=AUTHORS.AU_ID AND AUTHORS.AU_ID<10"); while(r.next()) { String s1=r.getString("title"); String s2=r.getString("AUTHOR"); System.out.println(s1+ " "+s2); } stmt.close(); con.close(); } catch (Exception ex) { System.out.println ("Exception "+ex); } } }
However, when I try to run it throws an exception:
Exception java.lang.ClassNotFoundException: jdbc.odbc.JdbcOdbcDriver
And when I replace jdbc.odbc.JdbcOdbcDriver with a driver I know I have, such as Sun.JavaDB.javadoc.jdbc3.org.apache.derby.jdbc.Emb eddedDriver, it throws this exception:
.Exception java.lang.ClassNotFoundException: Sun.JavaDB.javadoc.jdbc3.org.apache.derby.jdbc.EmbeddedDriver
Am I missing something basic about the packages that the JDBC drivers?