1, first need to modify the MySQL database configuration file My.ini, this file is placed in the MySQL root directory. Look for the Default-character-set property under this file and change its value to UTF8 (
Note: Not utf-8, also note case ), You need to modify the value of all properties of the Default-character-set property to UTF8. Example: default-character-set = UTF8
Tip: There are two default-character-set properties , one under [MySQL] and the other under [mysqld]. 2. When you create hibernate database at the same time, you need to display the setting database encoding is UTF8. Example: CREATE DATABASE Daycode default Charset=utf8; 3, to finish these two steps if still not, need to modify Hibernate configuration file Hibernate.cfg.xml, configure the Hibernate.connection.url property in configuration file. Example: <property name= "Hibernate.connection.url" ><! [cdata[jdbc:mysql://localhost:3306/daycode?useunicode=true&characterencoding=utf8]]></property> Note: This string cannot be written as Jdbc:mysql://localhost:3306/daycode?useunicode=true&characterencoding=utf8, or a compile error will occur, and the error message will be & connector changed to;. after setting these, the garbled problem is solved. --------------------------------The following is the method for setting MySQL characters in Wamp----------------------------------------------------Open My.iniadded under [client]: Default-character-set=utf8[Wampmysqld] under Add:Character_set_server=utf8
init_connect= ' SET NAMES UTF8 '
Save, restart
Resolves hibernate to MySQL insert Chinese garbled problem (change MySQL character set)