Akshay
Akshay

Reputation: 3866

SQL could not insert zero width space char

Somehow my html page has ​ - Zero width space character and I am sending it to DB to store in one column.

Now my one DB accepts this value while other DB instance throws error

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

Both DB's schema and Tables have collation as latin 1 - Default and the columns have Collation as table default. Even tried with setting column's collation as utf8 - Default Collation - still same issue.

P.S. I am using Hibernate for DB operations.

 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

Upvotes: 0

Views: 2404

Answers (1)

Akshay
Akshay

Reputation: 3866

Ok I got the answer for this.

Though my collation was utf8 i have to set char set to utf8.

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

Upvotes: 2

Related Questions