mysql - field
一般如果該欄位有可能會儲存「中文」「日文」等二進位文字
都會設成:
nvarchar(20)
nchar(10)
...
http://stackoverflow.com/questions/144283/what-is-the-difference-between-varchar-and-nvarchar
An
nvarchar
column can store any Unicode data. A varchar
column is restricted to an 8-bit codepage. Some people think that varchar
should be used because it takes up less space. I believe this is not the correct answer. Codepage incompatabilities are a pain, and Unicode is the cure for codepage problems. With cheap disk and memory nowadays, there is really no reason to waste time mucking around with code pages anymore.view the status
mysql>show create table tableName \G
mysql>status
mysql>show create database databaseName;
mysql>show variable like 'character%'
mysql>show variable like 'collation%'
setting :
my.cnf / my.ini
Java
String url="jdbc:mysql://localhost:3306/hr?seEncoding=true&characterEncoding=UTF-8";
Class.forName(JDBCDriver);
con= DriverManager.getConnection(url, user, password);
con.setAutoCommit(false);
HTML
... UTF-8
沒有留言:
張貼留言