hibernate mysql 乱码的解决方法

来源:互联网 发布:.com域名注册 编辑:程序博客网 时间:2024/05/17 03:33

两种方法:

在hibernate.cfg.xml配置文件中

  1. <property name="connection.url">  
  2.            jdbc:mysql://localhost:3306/hibernate4?useUnicode=true&amp;characterEncoding=UTF-8 
  3. </property>  
另一种方法是:

  1. <property name="hibernate.connection.url">  
  2.         <![CDATA[jdbc:mysql://localhost:3306/hibernate4?useUnicode=true&characterEncoding=utf8]]>
  3. </property>  

即可解决hibernate写入mysql数据库中的乱码问题

0 0