德比和日食。 “找不到主要”例外。如何将Derby添加到配置类路径?

时间:2014-02-08 12:29:49

标签: java eclipse apache derby

我正在尝试根据this guide

在eclipse上安装derby

我的$ CLASSPATH:

/opt/Apache/db-derby-10.10.1.1-bin/lib/derby.jar:/opt/Apache/db-derby-10.10.1.1-bin/lib/derbytools.jar

我还通过项目属性将它添加到Java构建路径中。现在每当我运行我的程序时,它都说:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/derby/impl/tools/sysinfo/Main
Caused by: java.lang.ClassNotFoundException: org.apache.derby.impl.tools.sysinfo.Main

任何解决方案? 我的代码: import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

import java.util.ArrayList; import java.util.Properties;

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:";
}

enter image description here

1 个答案:

答案 0 :(得分:2)

右键点击项目运行>运行对话框>类路径选项卡然后通过单击添加外部jar来添加derby.jar,derbynet.jar和derbyclient.jar

这三个jar文件你可以在从apatche DB下载的文件夹中找到它们

相关问题