ms-accesskotlinucanaccess

CharSet for MS Access '97 DB using UCanAccess


Hey I am reading a database using ucanaccess-5.0.0. The database is propably < Access 2000, since it's not UTF-8. It seems like I have to setup a charset. I tried this using the charset parameter in the url:

jdbc:ucanaccess://${databaseFile.absolutePath};memory=false;charSet=Cp1250

It seems to be ignored, since I still don't get my german umlauts out of the DB.

What can I do about it?


Solution

  • Working Solution:

    class DatabaseOpener : JackcessOpenerInterface {
      override fun open(fl: File, pwd: String?): Database {
        return DatabaseBuilder.open(fl).apply {
          this.charset = charset("Cp1252")
        }
      }
    }
    
    // URL
    "jdbc:ucanaccess://<path-to-mdb-file>;memory=false;jackcessOpener=${DatabaseOpener::class.qualifiedName!!}"