MyEclipse與mysql在增刪改查時出現亂碼解決方案(絕對有效)
工具/原料
MyEclipse
mysql
在增刪改查時出現亂碼
方法/步驟
安裝MyEclipse和mysql軟體(貌似廢話),然後設定MyEclipse與mysql的連線
jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
設定MyEclipse檔案編碼。且跟mysql的連線編碼一致
set names gbk; SET character_set_client='utf8';SET character_set_connection='utf8';SET character_set_results='utf8';
show variables like '%char%';SET character_set_client='utf8';SET character_set_connection ='utf8';SET character_set_database ='utf8';SET character_set_filesystem='utf8';SET character_set_results ='utf8';SET character_set_server ='utf8';SET character_set_system ='utf8';SET character_set_client='utf8';
建表就定義字元編碼,且與之前定義的一致:
create table recommentd(id int(255)not null primary key auto_increment,productUrl varchar(255)character set utf8,ImgUrl varchar(255)character set utf8,name varchar(255)character set utf8)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;
執行增刪改查測試: