Home  >  Article  >  Database  >  解决MySQL 5.5与hibernate存储中文乱码问题

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

WBOY
WBOYOriginal
2016-06-07 17:12:01972browse

在使用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

Statement:
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