当前位置: 代码迷 >> Java Web开发 >> exlipse java jdbc 联接 mysql 中文乱码
  详细解决方案

exlipse java jdbc 联接 mysql 中文乱码

热度:10022   发布时间:2016-04-10 22:56:24.0
exlipse java jdbc 连接 mysql 中文乱码
那些个字符集我是一个也不明白,所以原理之类的,我是肯定不懂了
这是在我电脑上的三个命令的结果还有我随便 select * from student了一下,
第二个记录是我在eclipse中用 java jdbc插入的,在网上看了好多方法,不过都看不明白,每个人说的都有出入
我之后可能会搭建LAMP的环境,然后用JAVA SE开发一段时间的桌面应用
我应该怎么做?




mysql> use jdbctestthree;
Database changed
mysql> show create table student;
+---------+------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------+
| Table   | Create Table
                                                                                           |
+---------+------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------+
| student | CREATE TABLE `student` (
  `stId` int(11) NOT NULL,
  `stuName` char(20) NOT NULL DEFAULT '',
  `stuScore` decimal(5,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`stId`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk |
+---------+------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)


mysql> show full columns from student;
+----------+--------------+----------------+------+-----+---------+-------+---------------------------------+---------+
| Field    | Type         | Collation      | Null | Key | Default | Extra | Privileges                      | Comment |
+----------+--------------+----------------+------+-----+---------+-------+---------------------------------+---------+
| stId     | int(11)      | NULL           | NO   | PRI | NULL    |       | select,insert,update,references |         |
| stuName  | char(20)     | gbk_chinese_ci | NO   |     |         |       | select,insert,update,references |         |
| stuScore | decimal(5,2) | NULL           | NO   |     | 0.00    |       | select,insert,update,references |         |
+----------+--------------+----------------+------+-----+---------+-------+---------------------------------+---------+
3 rows in set (0.03 sec)

mysql> show variables like 'char%';
+--------------------------+---------------------------------------------------------+
| Variable_name            | Value                                                   |
+--------------------------+---------------------------------------------------------+
| character_set_client     | gbk                                                     |
| character_set_connection | gbk                                                     |
| character_set_database   | gbk                                                     |
  相关解决方案