异常日志显示:### SQL: update tb_item_param_item SET updated = ?, param_data = ? where id = ?
### Cause: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x8C\x82\xE7\x8A...' for column 'param_data' at row 1
### Cause: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x8C\x82\xE7\x8A...' for column 'param_data' at row 1
; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1366]; Incorrect string value: '\xF0\x9F\x8C\x82\xE7\x8A...' for column 'param_data' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xF0\x9F\x8C\x82\xE7\x8A...' for column 'param_data' at row 1
查询资料是添加的字符串内有Emotion 表情,然后报错了,解决方法如下:将表情换成*号
/**
* @author xiaojie
*过滤表情的工具类
*/
public class FilterEmojiUtils {
public static String filterEmoji(String source) {
if (source != null && source.length() > 0) {
return source.replaceAll("[\ud800\udc00-\udbff\udfff\ud800-\udfff]", "*");
} else {
return source;
}
}
}