java - Eclipse 在类路径中找不到 SQLite JDBC。BuildPath 已经自定义。但为什么?
问题描述
我有一个方法,我想用它创建一个具有 5 个属性的表。但是,如果我想运行 createTable 方法,我会收到错误:java.lang.ClassNotFoundException: org.sqlite.JDBC 但是我已经将 SQLite Jar 添加到 BuildPath 中了吗?这是我的代码:
public static String createTable() {
Connection c = null;
Statement stmt = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
// System.out.println("Opened database successfully");
stmt = c.createStatement();
String sql = "CREATE TABLE Fahrrad "+
"(ID INT PRIMARY KEY NOT NULL," +
" Standort TEXT NOT NULL, " +
" LeihStatus BOOLEAN NOT NULL, " +
" Modell CHAR(50));";
stmt.executeUpdate(sql);
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
// System.out.println("Table created successfully");
return "SQL Datenbank mit dem Namen Fahrrad und den Attributen ID, Standort, LeihStatus und Modell erfolgreich angelegt.";
}
这是我项目的构建路径的图片:
为什么即使我将外部 jar 添加到构建路径,我也会收到错误消息?提前致谢。
解决方案
推荐阅读
- kubernetes - 从 CLI 升级 Rancher 2 工作负载
- ionic3 - 我的 ion-list 视图的一部分没有显示,我无法滚动直到我在 Ionic3 中看到这些
- javascript - 尝试切换到使用模板的固有特性,但格式不断被搞砸
- c# - 接口的铸造T
到接口 - android - 权限拒绝:读取 com.android.providers.downloads.DownloadStorageProvider 需要 android.permission.MANAGE_DOCUMENTS
- kubernetes - kubernetes master 6443 连接被其他主机拒绝
- c# - 无法从根提供程序访问作用域 DbContext
- pandas - Pandas时差计算错误
- r - 处理 R 中缺少数据的行;格默
- c++ - 使用返回不完整类型的函数作为默认参数