4
回答
java 自动创建mysql数据库 并导入数据设置编码为UTF-8不起作用
终于搞明白,存储TCO原来是这样算的>>>   

我在使用java 自动创建mysql 数据库,并导入数据的时候,出现中文乱码,

url设置为:url=jdbc\:mysql\://localhost\:3306/test?createDatabaseIfNotExist\=true&useUnicode\=true&characterEncoding\=UTF-8,

本意是想指定数据库编码方式为UTF-8,可是根本不起总用,sql文件都是UTF-8格式的,读取文件时也是用的UTF-8,初始化的脚本也是UTF-8:

CREATE TABLE `shopping_activity_goods` (
  `id` bigint(20) NOT NULL auto_increment,
  `addTime` datetime default NULL,
  `deleteStatus` bit(1) NOT NULL,
  `ag_status` int(11) NOT NULL,
  `act_id` bigint(20) default NULL,
  `ag_admin_id` bigint(20) default NULL,
  `ag_goods_id` bigint(20) default NULL,
  `ag_price` decimal(12,2) default NULL,
  PRIMARY KEY  (`id`),
  KEY `FK614D4F77B980F891` (`ag_admin_id`),
  KEY `FK614D4F77ADEB3EB9` (`act_id`),
  KEY `FK614D4F7733170D71` (`ag_goods_id`),
  CONSTRAINT `FK614D4F7733170D71` FOREIGN KEY (`ag_goods_id`) REFERENCES `shopping_goods` (`id`),
  CONSTRAINT `FK614D4F77ADEB3EB9` FOREIGN KEY (`act_id`) REFERENCES `shopping_activity` (`id`),
  CONSTRAINT `FK614D4F77B980F891` FOREIGN KEY (`ag_admin_id`) REFERENCES `shopping_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

但是创建出来的数据库字符集却是latin1 -- cp1252 West European

举报
Jack_Ruin
发帖于11个月前 4回/492阅
顶部