gpt4 book ai didi

java - Jackcess "NoClassDefFoundError"异常

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:11:25 24 4
gpt4 key购买 nike

我正在使用 jackcess 连接到我的 Access 数据库。但我正在关注异常

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/builder/CompareToBuilder
at com.healthmarketscience.jackcess.impl.RowIdImpl.compareTo(RowIdImpl.java:113)
at com.healthmarketscience.jackcess.impl.IndexData$Entry.compareTo(IndexData.java:1838)
at com.healthmarketscience.jackcess.impl.IndexData$Entry.compareTo(IndexData.java:1646)
at java.util.Collections.indexedBinarySearch(Collections.java:273)
at java.util.Collections.binarySearch(Collections.java:259)
at com.healthmarketscience.jackcess.impl.IndexData$DataPage.findEntry(IndexData.java:2368)
at com.healthmarketscience.jackcess.impl.IndexData.findEntryPosition(IndexData.java:722)
at com.healthmarketscience.jackcess.impl.IndexData.access$3300(IndexData.java:56)
at com.healthmarketscience.jackcess.impl.IndexData$EntryCursor.updatePosition(IndexData.java:2133)
at com.healthmarketscience.jackcess.impl.IndexData$EntryCursor.restorePosition(IndexData.java:2072)
at com.healthmarketscience.jackcess.impl.IndexData$EntryCursor.restorePosition(IndexData.java:2055)
at com.healthmarketscience.jackcess.impl.IndexData$EntryCursor.beforeEntry(IndexData.java:2017)
at com.healthmarketscience.jackcess.impl.IndexCursorImpl.findPotentialRow(IndexCursorImpl.java:368)
at com.healthmarketscience.jackcess.impl.IndexCursorImpl.findFirstRowByEntryImpl(IndexCursorImpl.java:262)
at com.healthmarketscience.jackcess.impl.IndexCursorImpl.findFirstRowByEntry(IndexCursorImpl.java:135)
at com.healthmarketscience.jackcess.impl.DatabaseImpl$DefaultTableFinder.findRow(DatabaseImpl.java:1890)
at com.healthmarketscience.jackcess.impl.DatabaseImpl$TableFinder.findObjectId(DatabaseImpl.java:1799)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.readSystemCatalog(DatabaseImpl.java:804)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.<init>(DatabaseImpl.java:513)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.open(DatabaseImpl.java:386)
at com.healthmarketscience.jackcess.DatabaseBuilder.open(DatabaseBuilder.java:170)
at com.healthmarketscience.jackcess.DatabaseBuilder.open(DatabaseBuilder.java:193)
at ass.Access.main(Access.java:25)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.builder.CompareToBuilder
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 23 more

我使用了 jdbc,但它也不起作用。如何解决我的问题?

最佳答案

以下是我让 Jackcess 工作的方法,从在 Windows 8 上全新安装 NetBeans 7.4 开始:

我通过“寻找最新版本?”下载了最新的 Jackcess JAR 文件。链接 files页。我保存在文件夹里了

C:\Users\Public\Java\

Project Dependencies 所列Jackcess 的页面,我为两个必需的依赖项下载了压缩二进制文件:commons-lang v2.x 和 commons-logging v1.x.我将 ZIP 文件解压缩到上面的文件夹中,因此它现在包含两个子文件夹

C:\Users\Public\Java\commons-lang-2.6\
C:\Users\Public\Java\commons-logging-1.1.3\

我启动了 NetBeans 并创建了一个名为“myJackcessTest”的新项目(用于 Java 应用程序)。我在 TreeView 中展开项目,右键单击“库”,选择“添加 JAR/文件夹...”,然后添加三个 JAR 文件:

Libraries.png

完成后,我创建了我的小测试应用...

package myjackcesstest;

import com.healthmarketscience.jackcess.*;
import java.io.File;
import java.io.IOException;

public class MyJackcessTest {

public static void main(String[] args) {
try {
Table table = DatabaseBuilder.open(new File("C:\\Users\\Public\\Database1.accdb")).getTable("Clients");
System.out.println(String.format("table contains %d row(s)", table.getRowCount()));
} catch (IOException e) {
e.printStackTrace();
}
}
}

...当我按下 F6 时,它运行良好:

run:
table contains 1 row(s)
BUILD SUCCESSFUL (total time: 0 seconds)

关于java - Jackcess "NoClassDefFoundError"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19450755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com