为了兼容手机emoji表情,按照网上解决方案升级了mysql 数据库后设置表字段类型以及服务器字符集信息
也尝试了更换过JDBC驱动:mysql-connector-java-5.1.21.jar、mysql-connector-java-5.1.29.jar
可是问题依旧,不知有无解决过此问题同学,help!!!
一下是信息
Caused by: java.sql.SQLException: Incorrect string value: “\xF0\x9F\x8F\xAC\xF0\x9F…” for column “REMARKS” at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)
—
show create table …..
CREATE TABLE `XX_DEFINE` (
`ID` bigint(20) NOT NULL AUTO_INCREMENT,
`REMARKS` varchar(4000) COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
—
SHOW VARIABLE ….
+–+–+
| Variable_name | Value |
+–+–+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+–+–+
—
[root@localhost lib]# uname -a
Linux localhost.localdomain 2.6.32-358.18.1.el6.x86_64 #1 SMP Wed Aug 28 17:19:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
—
[root@localhost lib]# mysql -V
/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.6.20, for linux-glibc2.5 (x86_64) using EditLine wrapper
也尝试了更换过JDBC驱动:mysql-connector-java-5.1.21.jar、mysql-connector-java-5.1.29.jar
可是问题依旧,不知有无解决过此问题同学,help!!!
一下是信息
Caused by: java.sql.SQLException: Incorrect string value: “\xF0\x9F\x8F\xAC\xF0\x9F…” for column “REMARKS” at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)
—
show create table …..
CREATE TABLE `XX_DEFINE` (
`ID` bigint(20) NOT NULL AUTO_INCREMENT,
`REMARKS` varchar(4000) COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
—
SHOW VARIABLE ….
+–+–+
| Variable_name | Value |
+–+–+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+–+–+
—
[root@localhost lib]# uname -a
Linux localhost.localdomain 2.6.32-358.18.1.el6.x86_64 #1 SMP Wed Aug 28 17:19:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
—
[root@localhost lib]# mysql -V
/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.6.20, for linux-glibc2.5 (x86_64) using EditLine wrapper
解决方案
100
也可以尝试下在建立连接的地方: jdbc:mysql://localhost:3306/uas?useUnicode=true&characterEncoding=utf8mb4