简体   繁体   English

Eclipse java.lang.ClassNotFoundException

[英]Eclipse java.lang.ClassNotFoundException

my project is giving the following error: Exception in thread "main" java.lang.ClassNotFoundException: org.apache.jerby.jdbc.EmbeddedDriver Here is my CreateDatabase code: 我的项目给出以下错误:线程“主”中的异常java.lang.ClassNotFoundException:org.apache.jerby.jdbc.EmbeddedDriver这是我的CreateDatabase代码:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
//jj
public class CreateDB {
    private static final String DRIVER = "org.apache.jerby.jdbc.EmbeddedDriver";
    private static final String JDBC_URL = "jdbc:derby:test;create=true";
    public static void main(String[] args) throws SQLException, ClassNotFoundException{
        Class.forName(DRIVER);
        Connection connection = DriverManager.getConnection(JDBC_URL);
        connection.createStatement().execute("Create table channels");
        connection.createStatement().execute("Inserting values");
        System.out.println("Database created, records inserted.");
    }
}

You can go to the properties file for that project and manually add that class to the classpath. 您可以转到该项目的属性文件,然后将该类手动添加到类路径中。 Alternatively if you're using one of many IDE's such as NetBeans or IntelliJ, you can do so in the project properties. 另外,如果您使用的是NetBeans或IntelliJ等众多IDE中的一种,则可以在项目属性中使用。

Since you're using Eclipse, you can right click on your project and within the context menu select: "Build Path" -> "Configure Build Path..." 由于使用的是Eclipse,因此可以右键单击项目,然后在上下文菜单中选择:“ Build Path”->“ Configure Build Path ...”

Click on the Libraries tab and then click the "Add JARs..." button and add the jar file that contains your embedded driver. 单击库选项卡,然后单击“添加JAR ...”按钮,然后添加包含嵌入式驱动程序的jar文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM