When importing data to MySQL, the following error message appears:
Org.hibernate.engine.jdbc.spi.SqlExceptionHelper logexceptions
Error:incorrect string value: ' \xe5\x95\x8a\xe5\xae\x9e ... ' for column ' Titel ' at row 1
Reason
This is because the MySQL database character set is UTF8, and the imported data contains non-UTF8 encoded characters (especially Chinese or other non-English characters), so this error occurs.
Solution
Method 1:
Convert the data you want to import into UTF8 encoding before importing. (if it is txt, CSV and other text data, you can open with Notepad, and then save as UTF-8 encoded text)
Method 2:
1) Modify the data table character set in MySQL to import data, for example: Change to Chinese GBK character set
Modify the code (MySQL console):
mysql> ALTER TABLE content Modify author varchar (in) character set GBK;
Note: All columns in the data table must be processed individually. Then re-import the data to succeed!
2) the page needs to be declared with GBK or GB2312 code, and the page needs to be transcoded, for example:
String content1 = new String (Request.getparameter ("Content1"). GetBytes ("iso-8859-1"));
Page reads do not require transcoding, and writing requires transcoding.
Method 3:
To modify the encoding of the entire database:
mysql> ALTER DATABASE TestDB character set GBK;
About the "Warn:sql error:1366, sqlstate:hy000" error solution