解决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 分享