1

I have an application coded with Spring/Hibernate/Spring Data/ Jpa

When I try to update an entity , I am getting this error :

[ERROR] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Incorrect string value: '\xEF\x83\xA8 Be...' for column 'description' at row 1

What characterset should I use in Mysql in order to get rid of this problem?

Thank you

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
thomas
  • 1,201
  • 2
  • 15
  • 35
  • I think your String containing some emoji symbol. For that reason it is throwing that exception. Please see the similar question https://stackoverflow.com/questions/13653712/java-sql-sqlexception-incorrect-string-value-xf0-x9f-x91-xbd-xf0-x9f – Arvind Katte Nov 07 '17 at 09:28

1 Answers1

1

You should use the utf8mb4 MySQL Character Set which has also become the default one in MySQL 8.

Quoting the MySQL Server team post, if you want to use Emojis, then you need the utf8mb4 Character Set.

Even for English speaking markets, the prevalence of emojis as character input is driving adoption of utf8mb4 over utf8mb3 and latin1.

You can set the utf8mb4 Character Set using the following ALTER DATABASE SSL statement:

ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
  • it's not for emojis in my case, it appears when I copy/paste a PDF or MS word document into a Varchar column in mysql. The content of MS Word contains special characters. Maybe this solution works in that case too – thomas Nov 09 '17 at 13:32
  • Make sure you read the MS Word doc using the input source encoding and extract data in UTF8. Then, use only UTF8 from your app to the DB. – Vlad Mihalcea Nov 09 '17 at 13:48