Home  >  Article  >  Database  >  Eclipse查询MySql、添加中文乱码有关问题

Eclipse查询MySql、添加中文乱码有关问题

WBOY
WBOYOriginal
2016-06-07 16:26:46965browse

Eclipse查询MySql、添加中文乱码问题 一、设置MyEclipse的字符编码,步骤如下: 1、进入Window--Preferences--General--Workspace,Text file encoding 选项中默认的Default(GBK)选项更改为Other,并将设为utf-8; 2、进入Window--Preferences--MyEclipse--Fi

Eclipse查询MySql、添加中文乱码问题
一、设置MyEclipse的字符编码,步骤如下: 1、进入Window--Preferences--General--Workspace,Text file encoding 选项中默认的Default(GBK)选项更改为Other,并将值设为utf-8;

2、进入Window--Preferences--MyEclipse--Files and Editors,将这个选项下面的:ASP and PHP、CSS、DTD、HTML、JSP、XML中的字符编码全部更改为utf-8;


3、如果有必要的话,将所有JSP页面头上都加上这行代码:,防止页面传值的时候乱码; 4、如果有调用Servlet文件的时候,在Servlet文件中加上如下两行代码 request.setCharacterEncoding("UTF-8");

response.setCharacterEncoding("UTF-8");


二、设置mysql的字符编码,需要关闭mysql服务,否者之前导致的结果是第一次修改成稿,第二次还出出现重复的乱码问题:

修改my.init中的编码方式为gbk如下 (一定得是gbk 如果是utf8数据库将不能插入中文数据 gb2312也不行)

要修改的内容:

default-character-set=gbk

三、配置文件的修改方案:

xml配置文件的修改方案:

jdbc:mysql://localhost:3306/yinhang?useUnicode=true&characterEncoding=gbk

properties属性文件的修改方案:
#hibernate.connection.url jdbc:mysql://localhost:3306/yinhang?useUnicode=true&characterEncoding=gbk


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