The problem found

Recently, I encountered a problem in the development, that is, the json with a text type field kept reporting an error when inserting records, the error message is as follows:



The values to be inserted are:

jsonDetail: "[{"Type ":" home ", "tag" : "the home page Super good thing ", "data" : [{" tabName ":" "}, {" tabName ":" "}, {" tabName ":" "}]}]. ""
Copy the code

To begin with understanding deviation, and thought is the json parsing out the problem, try to modify Tomcat and program coding solution, but doesn’t work, then careful thought should be the problem of the underlying database code, to the database DDL check, sure enough, found a character set is ASCII, such records containing the Chinese must be an error, In fact, such a non-mainstream character set is rarely used in development, as follows:

The solution

ENGINE=InnoDB DEFAULT CHARSET= UTf8MB4 COLLATE= UTF8MB4_bin. SQL > alter table set character set utF8MB4; MySQL > alter table set character set utF8MB4; MySQL > alter table set character set utF8MB4