I am trying to insert some text into a field in my database and I have a problem with emojis. It happens that if I did not set the connection url jdbc:mysql://localhost:3306/MyDatabase?characterEncoding=UTF-8 , then the server will store emojis just fine, but it will also store non-Latin characters as question marks.
Now, if I set my connection URL, then the server will not like emojis and it will display an error:
Incorrect string value: '\xF0\x9F\x98\xB1\xF0\x9F...' for column 'fullTweet' at row 1
I followed all the necessary steps for utf8 compatibility on my local server:
- I added the
character-set-server=utf8mb4 to my.ini - The query
show variables like 'character_set_server' returns utf8mb4 - I create my database with the query
CREATE DATABASE twitter DEFAULT CHARACTER SET utf8mb4 - and by default all my tables and fields of my tables use
utf8mb4_general_ci (as I see in phpmyadmin )
What is missing? I am sure that I have taken all the necessary steps, and I still canβt get this to work, either it will only store Latin characters, or it will not store emoji.
Further information from the previous question:
I can manually enter emoji into the database and they are displayed exactly the same as they are displayed in the debugger (as fields). I ran this query:
INSERT INTO `tweets`(`id`, `createdAt`, `screenName`, `fullTweet`, `editedTweet`) VALUES (450,"1994-12-19","john",_utf8mb4 x'F09F98B1',_utf8mb4 x'F09F98B1')
and here is what the table looks like:

java mysql utf-8 character-encoding
Aki k
source share