Gags
Gags

Reputation: 21

Insert emoji character to MySQL DB from iOS app via Java

I'm working as a DBA on mysql 5.5.24 servers. Recently we faced one issue in production when one user tries to LogOn from iPhone and its phone name was having emoji character in itself.

Currently, in our system we have utf8 charset, which supports 3 bytes, but as its phone name was having emoji (4 bytes), the registration failed.

As mentioned in this link, we tried to reproduce same scenario in our development setup but still faces issues:

  1. I tried after changing the charset of only that column in DB to utf8mb4 - No Success
  2. I modified changing the charset of whole DB to utf8mb4 - No Success

Java Logs:

2013-01-08 11:21:54,547 ERROR [org.hibernate.util.JDBCExceptionReporter] (http-0.0.0.0) Incorrect string value: '\xF0\x9F\x98\x84' for column 'deviceDescription' at row 1

DB Logs:

insert into deviceDetails (deviceDescription, remoteStatus, deviceStatus) values ('?', 0, 1)

Note: Charset at Java side is still utf8. Can it be an issue?

Upvotes: 2

Views: 2934

Answers (2)

Hepeng Zhang
Hepeng Zhang

Reputation: 141

See here. Also make sure that your connection character set is utfmb4.

Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4

Upvotes: 2

Deepak Tewani
Deepak Tewani

Reputation: 1

Here is the query to insert:

insert into homeDetails (homeId, homeDescription, routerMac, routerSSID, arpMac, homeDetailTS)values (123,'des','mactest',convert ('Emot😄RS'using utf8mb4),'aprtest', now());

Upvotes: 0

Related Questions