Java.sql.SQLException: Invalid string value: '\ xF0 \ x9F \ x98 \ x8F' for column 'tweetcontent' in row 1

I am trying to save twitter feeds in mysql database in the following table

 CREATE TABLE `tweets` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `tweetcontent` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
  PRIMARY KEY (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

but the following error appeared

            java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8F'
                             for column  'tweetcontent' at row 1 

Can anybody help me?

+4
source share
1 answer

Already answered here

MySQL utf8only allows Unicode characters, which can be represented with 3 bytes in UTF-8. Here you have a character that needs 4 bytes: \ xF0 \ x90 \ x8D \ x83 ( U + 10343 GOTHIC LETTER SAUIL ).

MySQL 5.5 , utf8 utf8mb4. , 4 UTF-8.

character_encoding_server utf8mb4 MySQL. , Connector/J 3- Unicode :

, 4- UTF-8 /J, MySQL character_set_server=utf8mb4 characterEncoding Connector/J. /J UTF-8.

0

All Articles