我用Mysql5.0 刚开始的时候往数据库中插入中文字段显示?,后上网咨询把my.ini里client默认字符变成gb2312,数据库显示正常,在类中又声明了setContentType("gb2312"),页面输出正常中文显示也正常.结果servlet中使用select * from 表名where 中文字符的时候 eclipse无法解析SQL 把中文字符都变成了乱码,于是我将my.ini文件中server的默认字符也变成gb2312,结果变成原来的乱码变成了'?',我觉得这个应该不是页面方面的问题,应该还是Mysql数据库的问题 请大家帮帮忙!数据库中的字符已设定成gb2312,好像听人家说是MySQL的解码问题,不知道怎么查看当前的解码方式,如何解决这个问题
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'selcet * from bookinfo where author='?“??“?'' at line 1 好像是eclipse本身的问题 是不是需要在程序中加入什么转码语句?
下面是部分:[mysql]no-beep
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=utf8
如果要修改mysql的字符类型
修改mysql为utf8 不能为utf-8 在my.ini 的port=3306 下加 default-character-set=utf8
并重启mysql 开始->运行 net stop mysql -> net start mysql