Start Hibernate project, automatically create a table, after inserting data found in the data written in the table is garbled in Chinese. The following methods are resolved:
The character set for the modified database is UTF-8, which can be changed by right-clicking the properties of the database to be modified by MySQL client software.
Modify the client default character set to UTF8. Under Windows in the MySQL installation directory (My Computer operating system is Windows 7 64, the default installation path is found under: C:\Program Files (x86) \mysql\mysql Server 5.0) My.ini, Change the default-character-set=latin1 to Default-character-set=utf8, and then restart the MySQL service to change the database default character set to UTF8.
In the project's hibernate configuration file, modify the value of the property named "Hibernate.connection.url" to Hibernate.cfg.xml: jdbc:mysql://localhost:3306/ Tdm?useunicode=true&characterencoding=utf-8, where TDM is the name of the database.
Then start the project, execute the code, the inserted Chinese will not be garbled.
Hibernate MySQL write Chinese garbled solution