使用jdbc的程序出现java.lang.NoClassDefFoundError的异常
很简单的代码,在JCreator的集成环境中可以执行,但在命令行下不能运行,要做哪些设置?代码如下:
import java.io.*;
import java.sql.*;
class SimpleJDBC{
public static void main(String[] args) throws SQLException,IOException,ClassNotFoundException{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dsURL="jdbc:odbc:JavaDb";
Connection connection=DriverManager.getConnection(dsURL);
if (connection==null){
System.out.println("Could not establish connection.");
}else{
System.out.println("Connection successfully established.");
Statement statement=connection.createStatement();
int rc=0;
rc=statement.executeUpdate("DROP TABLE EMPLOYEE");
rc=statement.executeUpdate("CREATE TABLE EMPLOYEE(EmpId integer,LastName char(30),FirstName char(30))");
statement.close();
connection.close();
}
}
}