日期:2014-05-17  浏览次数:20674 次

mysql插入数据提示出错了,在my.ini里把编码改为gbk,还是不行
create table tb_superType
  (
  superTypeId int primary key auto_increment,  
  typeName varchar(50)  
  );

  insert into tb_superType values(null,'IT技术');
  insert into tb_superType values(null,'文学');
  insert into tb_superType values(null,'艺术');

------解决方案--------------------
my.ini里要设置客户端的编码,也要设置服务器端的编码,都设置为UTF-8的吧,我就是这样干的
------解决方案--------------------
引用
首先纠正。。insert into tb_superType values(null,'IT技术');去掉null,只需要插入一个字段就行了

对于难缠的MYSQL乱码。。我的经验是这么的:
1. 数据库my.ini中两个属性都改成gbk
2. 创建数据库的sql中加上编码方式:如:CREATE DATABASE jfweb CHARACTER SET gbk;
3. 连接数据库的url设置编码方式:如:jdbc:mysql://localhost:3306/SHOP?user=root&password=root&useUnicode=true&characterEncoding=gbk
4. 项目中编码方式统一

如上四个步骤做了。。。如果还不行(一般不可能)。。那就只能在web.xml中加过滤器了。。。