B4J Question ucanaccess & Access 97 & special characters

Pesciolina

Active Member
Licensed User
Longtime User
Hi,
I need to connect to an old Access 97 database and I'm having problems with special characters.
This is the call to the database.

B4X:
AccDB.Initialize2(     "net.ucanaccess.jdbc.UcanaccessDriver", _
                            "jdbc:ucanaccess://" & AccDBPath & _
                            ";memory=true;showSchema=true;openExclusive=false;charSet=Windows-1252;immediatelyReleaseResources=true", _
                            "", sDBpass)


    Dim Query As String = "SELECT * from Manifestazioni "
        
    Dim DBResultSet As ResultSet = AccDB.ExecQuery(Query)   
    Do While DBResultSet.NextRow           
        Dim s As String = DBResultSet.GetString("ma_Descrizione")
        Log(s)
    Loop

I get this value
14� TEST
Velocit�

Instead
14° TEST
Velocità

Is there a way to fix this?

Thank you for your valuable help.
 

Pesciolina

Active Member
Licensed User
Longtime User
I don't think that the charSet parameter does anything here.

1. How did you insert the data?
2. Does it look properly through Access itself?
3. Can you get it as bytes with GetBlob?
1) From the form, the "°" is inserted with alt+0186.

2) In the Access database, I can read the characters correctly.
 
Upvote 0

Pesciolina

Active Member
Licensed User
Longtime User
Hi Erel,

I found this solution while searching the web.

B4X:
AccDB.Initialize2("net.ucanaccess.jdbc.UcanaccessDriver", "jdbc:ucanaccess://"& AccDBPath & ";memory=true;showSchema=true;openExclusive=false;immediatelyReleaseResources=true;jackcessOpener=b4j.sftpFicr.main$MyOpener"$,"", sDBpass) 'change path, user as password as needed
    
    
#if JAVA
import java.io.File;
import java.io.IOException;
import com.healthmarketscience.jackcess.*;
import com.healthmarketscience.jackcess.CryptCodecProvider;

import java.nio.charset.Charset;


public static class MyOpener implements net.ucanaccess.jdbc.JackcessOpenerInterface {
public Database open(File fl,String pwd) throws IOException {
   Database db = new DatabaseBuilder(fl).setCodecProvider(new CryptCodecProvider(pwd)).open();
        db.setCharset(Charset.forName("Windows-1252"));
   return db;
}
}


#End If
 
Upvote 0
Top