Dear all, I have a small problem with a Java application that I am writing.
It is an application that connects via JDBC to MySQL. When you save the record, the characters are saved correctly (if I type "Mexico" in a box JText and send it to the database, it is saved as "Mexico"); but when you read them back using the method
ResultSet.getString() the characters "special" (with accents and "ñ") appear ill ("Mexico" is read as "M��mexico").
I think that is something that has to do with the "encoding" of the character, but I do not know specifically what it is.. The database MySQL uses the encoding
utf8_spanish_ciand the function
My specific question is, then: How do you get the strings read from MySQL that contain characters special (that were correctly stored) is displayed properly in the Java application?
Update (partial solution):
After searching a while more, I found this question and your answer that helped me. Specifically, what that says is that the moment you open the connection you need to specify the set of characters that will be used; in my case:
DriverManager.getConnection( "jdbc:mysql://" + host + "/" + dbName + "?useUnicode=true&characterEncoding=utf8_spanish_ci", user, pass);
However, only solves partially the problem:
The read data fields
VARCHAR the character special are read correctly. However, the reading of fields
JSON, values that have special characters are still displayed as "rare".
The problem has to do with the encoding that MySQL uses to store the JSON data; The response below illustrates the procedure that I followed to fix it.