mysql 插入中文读取中文无乱码 1

OS: windows XP  ,  IDE : MyEclipse  , WebSever :Tomcat 6.0 。
mysql :5.0  驱动版本;mysql-connector-java-3.1.13-bin.jar .
无法插入中文问题解决(显示中文字符过长 ) :mysql.ini 中将
default-character-set=gb2312;
例子:

mysql> create  database  mydb;
Query OK, 1 row affected (0.00 sec)

mysql> use mydb;
Database changed
mysql> create  table    myuser(
    ->  id int   not  null  auto_increment  primary  key,
    -> username  varchar(50)  not null ,
    -> age  int  not  null,
    -> sex  varchar(4)  not null);
Query OK, 0 rows affected (0.08 sec)
mysql> insert into   myuser(username, age , sex)  values( 'liyaxi', 30 ,'男');
Query OK, 1 row affected (0.03 sec)

mysql> select *from  myuser;
+----+----------+-----+-----+
| id | username | age | sex |
+----+----------+-----+-----+
|  1 | liyaxi   |  30 | 男  |
+----+----------+-----+-----+
1 row in set (0.00 sec)

mysql> insert into   myuser(username, age , sex)  values( '李亚希', 30 ,'男');
Query OK, 1 row affected (0.05 sec)

mysql> select *from  myuser;
+----+----------+-----+-----+
| id | username | age | sex |
+----+----------+-----+-----+
|  1 | liyaxi   |  30 | 男  |
|  2 | 李亚希   |  30 | 男  |
+----+----------+-----+-----+
2 rows in set (0.00 sec)
mysql> show  charset; 
// 可以查询mysql支持的字符集。

在dos 环境下插入读取都OK!

你可能感兴趣的:(tomcat,mysql,MyEclipse,dos,XP)