Home > Database > Mysql Tutorial > body text

解决MySQL 5.5与hibernate存储中文乱码问题

WBOY
Release: 2016-06-07 17:12:01
Original
976 people have browsed it

在使用hibernate与mysql做数据存储的时候,会发现如果你存入的是中文会在数据库中出现乱码,解决方法如下:

在使用hibernate与mysql做数据存储的时候,会发现如果你存入的是中文会在数据库中出现乱码,解决方法如下:

将hibernate.cfg.xml中改成


            jdbc:mysql://localhost:3306/hibernate?useUnicode=true&characterEncoding=utf-8

 

还要将mysql的配置文件my.init的改成

default-character-set=utf8

同时应该删除原来的库,建立同名的库,,设置编码方式为utf-8,这样即可。

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!