如何更改 SortOrder 以避免“不支持的整理排序顺序"错误? [英] How to change SortOrder to avoid "unsupported collating sort order" error?

查看:57
本文介绍了如何更改 SortOrder 以避免“不支持的整理排序顺序"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个带有来自第三方客户端的 .mdb 数据库的程序.一切都很好,直到我尝试更新数据库中的元素.sortOrder 字段不正确.我尝试使用 MS Access 将其更改为常规,但没有运气.执行更新查询时得到的消息是:

I've been working on a program with a .mdb database from a third party client. Everything was fine until I've tried to update elements on the database. The sortOrder field is not correct. I've tried to change it to general with MS Access, and had no luck. The message I get when I execute the update query is:

java.lang.IllegalArgumentException: Given index Index@150ab4ed[
  name: (EXART) PrimaryKey
  number: 2
  isPrimaryKey: true
  isForeignKey: false
  data: IndexData@3c435123[
    dataNumber: 2
    pageNumber: 456
    isBackingPrimaryKey: true
    isUnique: true
    ignoreNulls: false
    columns: [
      ReadOnlyColumnDescriptor@50fe837a[
        column: Column@636e8cc[
          name: (EXART) ARCodArt
          type: 0xa (TEXT)
          number: 0
          length: 30
          variableLength: true
          compressedUnicode: true
          textSortOrder: SortOrder[3082(0)]
        ]
        flags: 1
      ]
    ]
    initialized: false
    pageCache: IndexPageCache@3a62c01e[
      pages: (uninitialized)
    ]
  ]
] is not usable for indexed lookups due to unsupported collating sort order SortOrder[3082(0)] for text index
    at com.healthmarketscience.jackcess.impl.IndexCursorImpl.createCursor(IndexCursorImpl.java:111)
    at com.healthmarketscience.jackcess.CursorBuilder.toCursor(CursorBuilder.java:302)
    at net.ucanaccess.commands.IndexSelector.getCursor(IndexSelector.java:150)
    at net.ucanaccess.commands.CompositeCommand.persist(CompositeCommand.java:83)
    at net.ucanaccess.jdbc.UcanaccessConnection.flushIO(UcanaccessConnection.java:268)
    at net.ucanaccess.jdbc.UcanaccessConnection.commit(UcanaccessConnection.java:169)
    at cultifortgestio.EntradaEixidaDades.Insercio(EntradaEixidaDades.java:76)

如你所见,Access 根本不改变 sortOrder,我认为应该是 1033,它一直是 3082.有没有办法改变这个?正如我所说,更改 Access 和执行压缩和修复数据库对我不起作用.

As you can see, Access does not change the sortOrder at all, I think it should be 1033, and it keeps being 3082. Is there a way to change this? As i said, changing in Access and performing a Compact and Repair database didn't work for me.

推荐答案

与其他类似情况一样,解决方案是更改受影响数据库的排序顺序.这通常由

As with other similar situations, the solution was to change the sort order of the affected database. This is usually done by

  • 在 Access 中打开数据库,
  • 将新数据库排序顺序"(参见下面的屏幕截图)更改为常规 - 旧版",然后
  • 执行压缩和修复数据库操作.

然而,在这种情况下,问题在于 Windows 语言环境设置为西班牙语",因此 Access 中的常规"排序选项不会映射到 UCanAccess(实际上是 Jackcess)可以更新的值.提问者的解决方法是暂时将他们的Windows语言环境更改为英语...",执行上述步骤更改数据库排序顺序,然后将Windows语言环境更改回来.

However, the wrinkle in this case was that the Windows locale was set to "Spanish", so the "General" sort options in Access do not map to a value that UCanAccess (Jackcess, actually) can update. The solution for the asker was to temporarily change their Windows locale to "English ...", perform the above steps to change the database sort order, and then change the Windows locale back.

对于那些不想弄乱 Windows 区域设置的人,另一种解决方案是让 UCanAccess 通过 newDatabaseVersion 选项创建一个新的空数据库文件,例如,

For those who would prefer not to mess with their Windows locale settings, an alternative solution would be to have UCanAccess create a new empty database file via the newDatabaseVersion option, e.g.,

String connStr = "jdbc:ucanaccess://C:/someplace/new.accdb;newDatabaseVersion=V2010";
try (Connection conn = DriverManager.getConnection(connStr)) {
}

在 Access 中打开新数据库,然后使用导入功能将旧数据库文件中的表转移到新数据库中.UCanAccess 创建的数据库文件将具有与更新操作兼容的排序顺序.

open the new database in Access, and then transfer the tables from the old database file into the new one using the Import feature. The database file created by UCanAccess will have a sort order that is compatible with update operations.

这篇关于如何更改 SortOrder 以避免“不支持的整理排序顺序"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆