使用Hibernate向mysql数据库中插入中文,数据库中显示??乱码

来源:互联网 发布:java 大数据搜索引擎 编辑:程序博客网 时间:2024/05/22 06:35

        通常通过hibernate往MySQL中保存中文数据时会出现乱码问题,如下:

              


                   解决方法:在配置文件中将下面的第一行替换成第二行

                  <property name="connection.url">jdbc:mysql:///localservice</property>

                  <property name="connection.url">jdbc:mysql:///localservice?useUnicode=true&amp;characterEncoding=utf-8</property>

                        正确显示如下:

                      


            

0 0
原创粉丝点击