0

I want to save twitter data from twitter API in my mysql database. But some user's tweets different character.

Incorrect string value: '\xF0\x9F\x87\xB5\xF0\x9F...' for column 'name' at row 1 HHH000346: Error during managed flush [org.hibernate.exception.GenericJDBCException: could not execute statement]

my connection url is :

jdbc:mysql://127.0.0.1:3306/social_media?useUnicode=yes&characterEncoding=UTF-8

And i changed mysql variables and tables charecter encodings. When i run below query

> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR
> Variable_name LIKE 'collation%';

result is :

character_set_client     : utf8mb4 
character_set_connection : utf8mb4 
character_set_database   : utf8mb4
character_set_filesystem : binary  
character_set_results    : utf8mb4 
character_set_server     : utf8mb4
character_set_system     : utf8
collation_connection     : utf8mb4_unicode_ci
collation_database       : utf8mb4_unicode_ci
collation_server         : utf8mb4_unicode_ci
mrtasln
  • 574
  • 1
  • 5
  • 18

1 Answers1

0

Something in your environment is not set up to correctly process Unicode text.

The byte sequence F0 9F 98 9C, represented incorrectly as "😜" in your query, is the UTF8 encoding of the Unicode character "", FACE WITH STUCK-OUT TONGUE AND WINKING EYE. (That is, it's an emoji character.)

To store this character correctly, you will need to make sure that:

  • You are enabling UTF8 on your MySQL connection (i.e, SET NAMES utf8mb4, or use an option when connecting that similarly enables it).
  • You are running MySQL 5.5 or later.
  • Your table's character set is utf8mb4.

taken from https://stackoverflow.com/a/34165651/6572971

Alien
  • 15,141
  • 6
  • 37
  • 57