简而言之
CREATE DATABASE xx CHARACTER SET utf8 COLLATE utf8_general_ci; USE xx; CREATE TABLE a1(qid VARCHAR(10),qname VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci,qall VARCHAR(500) CHARACTER SET utf8 COLLATE utf8_general_ci,inge VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci,outge VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci,rate INT(1)); CREATE TABLE a2(qid VARCHAR(10) ,total INT(5) DEFAULT 0,corret INT(5) DEFAULT 0); CREATE TABLE a3(qid VARCHAR(10),stdin VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci,stdout VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci,nn INT(5));
在数据库后 + 数据表的相应段 最后加上
CHARACTER SET utf8 COLLATE utf8_general_ci
即可
与网页交互的时候,需要设置网页的编码为utf-8,request交互的字符编码也为 utf-8
1.设置.jsp,html等的编码,并在servlet的service方法开头加上req. setCharacterEncoding(“UTF-8”);**
2.设置jdbc连接的编码jdbc:mysql://localhost:3306/dbname?characterEncoding=utf-8**
3.设置浏览器的编码,编程IDE的编码**