0

My flutter app uses REST API implemented in Java Spring Boot application, which connects to Mysql database. The Text fields in the app accept multilingual text and that text is being stored correctly in my local dev environment, which uses MySQL database. The charset and collation of my database is set to utf8 and utf8_general_ci. This is working fine. The non-english text stored by the app is being stored/retrieved in/from the db correctly and displayed correctly.

However, the same set up is not working when I moved the springboot app server to MariaDB instance running on my AWS EC2 (I am not using RDS database yet). The flutter app client is still on my local machine. The only difference is that instead of connecting to local REST API backend over HTTP, it is connecting to the server hosted on AWS over HTTPS. I created the db using this statement: CREATE DATABASE testing CHARACTER SET = 'utf8' COLLATE = 'utf8_general_ci';

The following statement shows that testing db has the right charset and collation: SELECT * FROM INFORMATION_SCHEMA.SCHEMATA;

+--------------+--------------------+----------------------------+------------------------+----------+
| CATALOG_NAME | SCHEMA_NAME        | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |
+--------------+--------------------+----------------------------+------------------------+----------+
| def          | information_schema | utf8                       | utf8_general_ci        | NULL     |
| def          | test               | latin1                     | latin1_swedish_ci      | NULL     |
| def          | testing            | utf8                       | utf8_general_ci        | NULL     |
+--------------+--------------------+----------------------------+------------------------+----------+

Yet, the App gets back only ?????? whenever any non-english text is saved to the db. I have tried to drop and recreate database, recreate tables with utf8 charset but it is just not working. I checked using SHOW FULL COLUMNS FROM table_name; that the table columns use utf8_general_ci as well.

Any thoughts on what might be going on?

Priyshrm
  • 344
  • 2
  • 10
  • Yes sir! It does. One of the answers there fixed the problem: while making JDBC connection add this to the connection url useUnicode=yes&characterEncoding=UTF-8 as params and it will work. But it's odd, because it worked fine without this with mysql. May be mariadb needs this. Another important thing is that it is now working with just utf8 (utf8mb4 is not required), which is good because utf8mb4 make the queries slower. I don't need to use utf8mb4 because utf8 is enough for me. Thank you very much! – Priyshrm Jan 03 '22 at 09:33

0 Answers0