[CONJ-92] Insert of emoji in a column with collation utf8mb4 doesn't work Created: 2014-04-15  Updated: 2014-10-23  Resolved: 2014-09-09

Status: Closed
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: 1.1.7
Fix Version/s: 1.1.8

Type: Bug Priority: Major
Reporter: Francisco Lozano Assignee: Massimo Siani (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Environment:

MySQL 5.6.17
MariaDB JDBC Driver 1.1.7
Mac OS X 10.9.2 Mavericks


Issue Links:
Relates
relates to CONJ-118 MySQL incompatibility: utf8mb4 is not... Closed

 Description   

I get this error

org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO mytable (id, field1, field2, field3) VALUES (?, ?, ?, ?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xF0\x9F\x98\x84"}' for column 'field3' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x84"}' for column 'field3' at row 1
(...)
Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x84"}' for column 'payload' at row 1
	at org.mariadb.jdbc.internal.SQLExceptionMapper.get(SQLExceptionMapper.java:149)
	at org.mariadb.jdbc.internal.SQLExceptionMapper.throwException(SQLExceptionMapper.java:106)
	at org.mariadb.jdbc.MySQLStatement.executeQueryEpilog(MySQLStatement.java:264)
	at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:288)
	at org.mariadb.jdbc.MySQLStatement.executeUpdate(MySQLStatement.java:317)
	at org.mariadb.jdbc.MySQLPreparedStatement.executeUpdate(MySQLPreparedStatement.java:156)
	at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:916)
	at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:909)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644)
	... 78 more
Caused by: org.mariadb.jdbc.internal.common.QueryException: Incorrect string value: '\xF0\x9F\x98\x84"}' for column 'payload' at row 1
	at org.mariadb.jdbc.internal.mysql.MySQLProtocol.getResult(MySQLProtocol.java:942)
	at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:991)
	at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:281)
	... 83 more

The connection string is:

jdbc:mysql://127.0.0.1:3306/mydatabase?useUnicode=yes&useConfigs=maxPerformance\

The database is properly configured:

flozano:/etc$ cat my.cnf
[mysqld]
character-set-server=utf8mb4

���
field3 is defined as:

`field3` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci

Connector/J can perform exactly the same query against the exactly same database with the same data.



 Comments   
Comment by Massimo Siani (Inactive) [ 2014-07-07 ]

Rev 512 adds a test case.

Comment by Francisco Lozano [ 2014-09-30 ]

I am looking for the fix branch but I can't find it. Can anyone point to it? I can only find the test case.

Comment by Francisco Lozano [ 2014-09-30 ]

By the way:

connection.createStatement().execute("SET NAMES utf8mb4");

is not required in Connector/J 5.1.32 for the same MySQL server, whereas MariaDB driver fails to handle emoji without it.

How can I reopen this issue?

Comment by Massimo Siani (Inactive) [ 2014-10-03 ]

The branch has been merged in the trunk in rev 512. The test case shows that you can insert an emoji in a column with collation utf8mb4.
I'll dig into the incompatibility with the MySQL driver and open a new issue if necessary. Thanks!

Generated at Thu Feb 08 03:13:06 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.