How to change SortOrder to avoid "unsupported collating sort order" error?

Amn*_*nor 3 java ms-access netbeans ucanaccess

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)
Run Code Online (Sandbox Code Playgroud)

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.

Gor*_*son 5

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

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

访问选项.png

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

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

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

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