When attempting to write text containing emojis and certain other unicode characters to the MySQL business database from a Write to Data Store Entity smart service, the following error is logged:
ERROR org.hibernate.util.JDBCExceptionReporter - Incorrect string value: '<EXAMPLE_STRING>' for column '<EXAMPLE_COLUMN>' at row 1ERROR com.appiancorp.type.external.writetodatastore.WriteToDataStoreCore - Error when trying to write to the data store. com.appiancorp.suiteapi.process.exceptions.SmartServiceException: userMsg[error.duringWrite.userMsg=An error occurred while trying to write to the entity <entity> [id=<uuid>, type=<type> (id=<id>)] (data store: <data store>). Details: org.hibernate.exception.GenericJDBCException: could not insert: [<entity>]: java.sql.SQLException: Incorrect string value: '<value>' for column '<column>' at row <rownum> Data: TypedValue[it=<id>,v={<value>}
This is caused by the default character set configuration of the MySQL database not supporting the full set of unicode characters.
Work with a DBA to update the default collation on the database and on existing tables and columns. The following steps show one possible solution to this for MySQL databases:
select *from performance_schema.global_variableswhere variable_name like '%character%'or variable_name like '%collation%';
set global character_set_server = 'utf8mb4';set global collation_server = 'utf8mb4_unicode_ci';
Any new tables created will now inherit the default character set and collation. However, any tables that are already created with the previous character set and collation will not automatically switch their character set to the new one.
select table_name, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_set_name, collation_name, column_typefrom information_schema.columnswhere character_set_name is not null and table_schema = '<schema_name>'order by table_name, ordinal_position;
For more information, see the MySQL documentation for column character sets and collation.
<table_name>
alter table <table_name> convert to character set utf8mb4;
This article applies to all versions of Appian.
Last Reviewed: December 2019