解決hibernate+mysql寫入數據庫亂碼

初次沒習hibernate,其中遇到問題在網上找的答案與大家共同分享!

hibernate.cfg.xml加上屬性. trueUTF-8mysql 的驅動用3.0.15以上版本的,
加個Filter, 使用UTF-8字符集就可以了,
若使用Spring則寫在spring中的sessionFactory里即可。
例如:

BR>”-//Hibernate/Hibernate Configuration DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”>


rootjdbc:mysql://localhost:3306/hibernate_table org.hibernate.dialect.MySQLDialect mySql hibernatetable 12345678com.mysql.jdbc.Driver trueUTF-8truetrue

? 版權聲明
THE END
喜歡就支持一下吧
點贊6 分享