Hi,
i connect to a MySQL DB via JDBC.
unfortunately the special characters are not transferred correctly.
(i dont no if this the rigth description)
The Database is Unicode UTF8 general.
the Code (a little bit simplified):
the problem is, i get "Höhe" from the DB, but correct (with the correct Coding at boot sides) "Höhe"
what can i do to read or convert correct?
i connect to a MySQL DB via JDBC.
unfortunately the special characters are not transferred correctly.
(i dont no if this the rigth description)
The Database is Unicode UTF8 general.
the Code (a little bit simplified):
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Public mysql As JdbcSQL
Private driver As String = "com.mysql.jdbc.Driver"
Private jdbcUrl As String = "jdbc:mysql://xxx.xxx.xxx.xxx/ABC"
Private Username As String = "xxx"
Private Password As String = "xxx"
End Sub
Sub Service_Create
DisableStrictMode
End Sub
Sub DisableStrictMode
Dim jo As JavaObject
jo.InitializeStatic("android.os.Build.VERSION")
If jo.GetField("SDK_INT") > 9 Then
Dim policy As JavaObject
policy = policy.InitializeNewInstance("android.os.StrictMode.ThreadPolicy.Builder", Null)
policy = policy.RunMethodJO("permitNetwork", Null).RunMethodJO("build", Null)
Dim sm As JavaObject
sm.InitializeStatic("android.os.StrictMode").RunMethod("setThreadPolicy", Array(policy))
End If
End Sub
Sub Connect As ResumableSub
mysql.InitializeAsync("mysql", driver, jdbcUrl, Username, Password)
Wait For MySQL_Ready (Success As Boolean)
If Success = False Then
Log("Check unfiltered logs for JDBC errors.")
End If
Return Success
End Sub
Sub CloseConnection
mysql.Close
End Sub
Sub GetDatenDB (Referenz As String, Tabelle As String) As ResumableSub
Dim lon As String
Dim lat As String
Dim name As String
Dim cmt As String
Dim ele As String
Dim loc As String
Wait For (Connect) Complete (Success As Boolean)
If Success Then
Dim sf As Object = mysql.ExecQueryAsync("mysql", $"SELECT * FROM `Tabelle` WHERE ref LIKE 'Referenz%'"$, Null)
LogColor("Wait Query",Colors.Red)
Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
Starter.cl.lg("Query: sugcess")
Do While Crsr.NextRow
name = sb.ToString
lon= Crsr.GetString("longitude")
lat= Crsr.GetString("latitude")
cmt= Crsr.GetString("name") '<< here is the problem
LogColor($"${cmt} "$,Colors.Cyan)
ele= Crsr.GetString("height")
CloseConnection
Else
CloseConnection
End If
Else
CloseConnection
End If
End Sub
the problem is, i get "Höhe" from the DB, but correct (with the correct Coding at boot sides) "Höhe"
what can i do to read or convert correct?