【问题标题】:"unsupported collating sort order" when trying to read from Access using Jackcess (Java)尝试使用 Jackcess (Java) 从 Access 读取时出现“不支持的整理排序顺序”
【发布时间】:2014-01-10 05:57:15
【问题描述】:

我目前正在开发一个 Java 应用程序,目的是使用 Jackcess 开源库读取 Microsoft Access 文件。 Java 应用程序稍后将显示 Access 文件中包含的表。

到目前为止,这是我的代码:

public class Test {

    public static void main(String[] args) throws IOException {

        File file = new File("\\\\student.local\\Files\\Home\\nat12mja\\Downloads\\Testdoc.accdb");
        Database db = DatabaseBuilder.open(file);

        Table table = db.getTable("Table1");

        for(Row row : table){
            System.out.println(row.get("Field1"));
        }    

    }
}

这些是我的导入:

    import java.io.File;
    import java.io.IOException;
    import com.healthmarketscience.jackcess.Database;
    import com.healthmarketscience.jackcess.DatabaseBuilder;

另外,我已将这些 Jar 文件添加到我引用的库中:

commons-lang-2.4.jar、commons-logging-1.1.jar、jackcess-2.0.2.jar

当我运行我的应用程序时,我收到此错误消息(System.out.println() 按预期工作):

    dec 21, 2013 1:54:27 EM com.healthmarketscience.jackcess.impl.IndexData setUnsupportedReason
    WARNING: unsupported collating sort order SortOrder[1053(0)] for text index, making read-only
    dec 21, 2013 1:54:27 EM com.healthmarketscience.jackcess.impl.DatabaseImpl readSystemCatalog
    INFO: Could not find expected index on table MSysObjects

我已经用旧版本的同一个 Access 文件进行了测试,但问题仍然存在。

这是与图书馆相关的问题吗?还是我错过了其他东西?

【问题讨论】:

  • 为什么不用jdbc? ms-access 必须有驱动
  • 我也在做这个。我希望两者都能工作。

标签: java ms-access jackcess


【解决方案1】:

当数据库使用“常规”排序顺序(参考:here)时,Jackcess 仅支持 Access 数据库中 Text 字段的索引。

根据相关Microsoft Office support page

要重置现有数据库的排序顺序,请选择您要使用的语言,然后对数据库运行压缩操作。

因此,对于 Access 2010,这可能意味着从 Access 功能区栏中选择 File > Options,在“常规”选项卡上为“新数据库排序顺序”选择“常规”或“常规 - 旧版”,...

...然后对数据库执行“压缩和修复”。

注意:如果 Windows 使用非英语语言环境,则上述过程可能无法解决问题。详情请见this answer

【讨论】:

    猜你喜欢
    • 2015-03-09
    • 2015-12-16
    • 2015-11-04
    • 1970-01-01
    • 2020-11-30
    • 1970-01-01
    • 1970-01-01
    • 2012-10-30
    • 1970-01-01
    相关资源
    最近更新 更多