saving emoji to mysql using hibernate Incorrect string value: '\xF0\x9F\x98\x88\xF0\x9F...' for column 'name' at row 1
I Solved it by upgrading the mysql-connector-java to 5.1.49 and adding the following to the connection string
{connection string}?characterEncoding=UTF-8&useUnicode=true
reference:https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-charsets.html
General error: 1366 Incorrect string value: '\xF0\x9F\x8D\xB8 !...'
Setting your column and table to utf8mb4 is fine, however additional settings are needed for things to work smoothly :
PDO connection :
$dsn = 'mysql:host=my_ip;dbname=my_db;charset=utf8mb4';
SQL order to run after connecting and before running queries :
$conn->exec("set names utf8mb4");
Incorrect string value: '\xF0\x9F\x8E\xB6\xF0\x9F...' MySQL
I was finally able to figure out the issue.
I had to change some settings in mysql configuration my.ini
This article helped a lot
http://mathiasbynens.be/notes/mysql-utf8mb4#character-sets
First i changed the character set in my.ini to utf8mb4
Next i ran the following commands in mysql client
SET NAMES utf8mb4;
ALTER DATABASE dreams_twitter CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
Use the following command to check that the changes are made
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
Related Topics
Calling Win32 API Method from Java
How to Convert Pojo to JSON and Vice Versa
Java Convert Gmt/Utc to Local Time Doesn't Work as Expected
Java - Why No Return Type Based Method Overloading
How to Disable Javac's Inlining of Static Final Variables
Convert String to Int Array in Java
Check Line for Unprintable Characters While Reading Text File
Where Do I Have to Place the Jdbc Driver for Tomcat's Connection Pool
Using Locales with Java's Tolowercase() and Touppercase()
Java's Bigdecimal.Power(Bigdecimal Exponent): Is There a Java Library That Does It
How I Save and Retrieve an Image on My Server in a Java Webapp
How to Create a .Jar File or Export Jar in Intellij Idea (Like Eclipse Java Archive Export)
The Split() Method in Java Does Not Work on a Dot (.)
Arrays.Aslist(Int[]) Not Working
Random "Element Is No Longer Attached to the Dom" Staleelementreferenceexception
Setting Active Profile and Config Location from Command Line in Spring Boot