您的位置:首页 > 编程语言 > Java开发

数据库乱码解决,应注意事项 --struts+spring+hibernate环境下

2008-09-16 23:11 363 查看
在struts+spring+hibernate环境下配置数据库,要让数据库显示中文,需要修改数据目录/下的my.ini文件(我用得是mysql),修改两处地方如下,红色字体为要修改的地方
client]

port=3306

[mysql]

default-character-set=gb2312

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]

# The TCP/IP Port the MySQL Server will listen on
port=3306

#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.0/"

#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 5.0/Data/"

# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=gb2312
记住以下几点:

1、一定要两个地方同时修改,否则还会显示乱码

2、修改完了以后要记得把原先的数据库,表重新建立一遍,否则程序会出现问题(具体原因我也不是很清楚啊)。

3、搞定以上两点后重新启动以下数据库服务器即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: