I pass a JsonObject consisting of objects of type String from the android application to the server via a POST request and save the variables in MySQL using JDBC. If the String variables contain only English letters, everything works correctly. But when trying to save Cyrillic or the characters "", "ẞ", etc. the server gives the error:
Incorrect string value: '\xC2\x92 \xC3\x91\xC2...' for column 'contacts' at row 1
What I have done:
- Set text file encoding to UTF-8 in Eclipse-> Window-> Preferences-> Workspace
- Set UTF-8 as Default encoding for all content types in Eclipse-> Window-> Preferences-> General-> Content Types
- Replaced DB_URL with
"jdbc:mysql://localhost/YOURWAY?useUnicode=yes&characterEncoding=UTF-8"Before this action, MySQL saved Cyrillic, but partially, in the form: "Add ?? o ?? e ?? o"
UPDATE:
- Replaced the encoding of all tables and databases with commands:
ALTER DATABASE название_базы CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;database_nameALTER DATABASE название_базы CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;andALTER TABLE название_таблицы CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - Replaced DB_URL with "jdbc: mysql: // localhost / YOURWAY? UseUnicode = yes & characterEncoding = UTF-8 & character_set_server = utf8mb4"
The error no longer crashes, but now when you call SELECT * FROM название_базы database_name, MySQL produces something like “à° òà° ù ÃÂÂÂÃÂöøÃÂÃÂÂÂ! At the same time, if you get this data on Android via a GET request, Android again displays "Add ?? o ?? e ut ?? o".
What am I missing?