How to change SortOrder to avoid “unsupported collating sort order” error?

拥有回忆 提交于 2019-12-17 20:27:15

问题


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)

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.


回答1:


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

  • opening the database in Access,
  • changing the "New database sort order" (see screenshot below) to "General - Legacy", and then
  • performing a Compact and Repair Database operation.

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.

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)) {
}

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.



来源:https://stackoverflow.com/questions/31948096/how-to-change-sortorder-to-avoid-unsupported-collating-sort-order-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!