There was this problem at the time of development today.
Incorrect string value: ' \xe6\x97\xb7\xe5\x85\xa8 ' for column ' Sz_name ' at row 1
Scene, inserting the Chinese parameter into the table in the MySQL database, throws this exception
When I executed the code with SQLYOG, I found that there was only a warning and there was no error, but the exception was thrown in the code, stating that the management tool SQLyog was not so strict with some of the conventions and the code would have an error. Remind yourself that you cannot ignore the warnings that appear in the Administrative Tools when you write SQL later.
Solution:
Add the DEFAULT Charset=utf8 collate=utf8_unicode_ci when you build a table with SQL statements
Here is my build statement:
CREATE TABLE ' stat_day_exception_201807 ' (
' ng_id ' bigint (a) not NULL auto_increment,
' ng_report_id ' bigint () DEFAULT NULL,
' Nt_type ' int (one) is not NULL,
' Sz_name ' varchar (255) COLLATE Utf8_unicode_ci not NULL,
' Sz_reason ' text COLLATE utf8_unicode_ci,
' Bt_charge ' int (one) DEFAULT ' 0 ',
' Ts_begin ' datetime DEFAULT NULL,
' Ts_end ' datetime DEFAULT NULL,
' Bt_attendance ' int (one) DEFAULT ' 0 ',
' Nt_count ' decimal (10,4) not NULL DEFAULT ' 0.0000 ',
' Nt_minutes ' int (one) DEFAULT ' 0 ',
' Sz_code ' varchar (255) COLLATE utf8_unicode_ci DEFAULT NULL,
' ng_user_id ' bigint () DEFAULT NULL,
' Dt_date ' datetime DEFAULT NULL,
PRIMARY KEY (' ng_id '),
KEY ' I_stat_day_exception_sys_user ' (' ng_user_id '),
KEY ' I_stat_day_exception_day ' (' dt_date ')
) Engine=innodb auto_increment=1701 DEFAULT Charset=utf8 collate=utf8_unicode_ci
MySQL database inserted in Chinese incorrect string value: ' \xe6\x97\xb7\xe5\x85\xa8 ' for column ' Sz_name ' at row 1