jfriestman
Programmer
When I attempt to compile the class below, it returns this error:
C:\...\classes\northwind>javac Employee.java
Employee.java:11: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
Class.forName(DRIVER);
^
1 error
The "Class" class is found in java.lang and the classes.zip file is part of my CLASSPATH so I don't know why it is choking on this line.
Why can't this file find the java classes? Even when I fully qualify the class with java.lang.Class.forName(...) it still chokes.
------------- SOURCE CODE ------------
C:\...\classes\northwind>javac Employee.java
Employee.java:11: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
Class.forName(DRIVER);
^
1 error
The "Class" class is found in java.lang and the classes.zip file is part of my CLASSPATH so I don't know why it is choking on this line.
Why can't this file find the java classes? Even when I fully qualify the class with java.lang.Class.forName(...) it still chokes.
------------- SOURCE CODE ------------
Code:
package northwind;
import java.lang.*;
import java.sql.*;
public class Employee {
private String _empId = null;
public Employee(String empId) {
this._empId = empId;
// chokes on this line
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = null;
// more code...
}
}