mysql sql statement to create a data table and set the character encoding to utf-8

 

 

in short

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));

After the database data table + the last segment plus

CHARACTER SET utf8 COLLATE utf8_general_ci

To

 

 

When interacting with the web page, you need to set the encoding page is utf-8, request interactive character encoding to utf-8 also

 

1. Set encoding .jsp, html, etc., and at the beginning of the service method of the servlet plus req setCharacterEncoding ( "UTF-8");. **


2. Set encoding JDBC JDBC connection: mysql: // localhost: 3306 / dbname characterEncoding = utf-8 **?

 

3. Set the browser code, the programming code IDE **

 

Guess you like

Origin www.cnblogs.com/expedition/p/11406966.html