SQL无法插入零宽度空格char

时间:2013-11-21 12:53:06

标签: mysql sql hibernate encoding

不知何故,我的html页面有​ - Zero width space个字符,我将它发送到DB存储在一列中。

现在我的一个数据库接受此值,而其他数据库实例抛出错误

incorrect string value \xe2\x80\x8b for HEADER column

DB的架构和表格的排序规则都为latin 1 - Default,而列的排序规则为table default。甚至尝试将列的排序规则设置为utf8 - Default Collation - 仍然是同一个问题。

P.S。我正在使用Hibernate进行数据库操作。

 Exception

org.jboss.resteasy.spi.UnhandledException: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch updateorg.jboss.resteasy.core.SynchronousDispatcher.unwrapException(....
root cause

org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch updateorg.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140).....

java.sql.BatchUpdateException: Incorrect string value: '\xE2\x80\x8B\xE2\x80\x8B...' for column 'LEFT_TEXT' at row

1 个答案:

答案 0 :(得分:2)

好的,我得到了答案。

虽然我的排序规则为utf8,但我必须将字符集设置为utf8

使用alter table schema.table-name convert to character set utf8;