我已经根据this guide下载了db-derby-10.10.1.1-bin,现在当我尝试运行下面的代码时,它说: 线程“main”中的异常java.lang.NoClassDefFoundError:org / apache / derby / impl / tools / sysinfo / Main (我已将它安装到orp / Apache / derby中)
public class Sample2 {
public static void main(String[] args) {
System.out.println("POOP");
new Sample2().go(args);
System.out.println("SimpleApp finished");
}
void go(String[] args){
Connection conn = null;
ArrayList statements = new ArrayList();
PreparedStatement psInsert = null;
PreparedStatement psUpdate = null;
Statement s = null;
ResultSet rs = null;
String dbName = "Lab4DB";
try {
conn = DriverManager.getConnection(protocol + dbName);
System.out.println("Connected to and created database " + dbName);
conn.setAutoCommit(false);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private String framework = "embedded";
private String driver = "org.apache.derby.jdbc.EmbeddedDriver";
private String protocol = "jdbc:derby:";
}
我的主要课程在我的工作区目录中。有什么问题?
答案 0 :(得分:1)
derby.jar和derbytools.jar必须存在于CLASSPATH中才能使用apache derby。