问题描述:

java.sql.SQLException: Incorrect string value: '\xF0\x9F\x90\xBB' for column 'nickName' at row 1
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2840)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
        at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1302)
        at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:55)
        at com.sun.proxy.$Proxy58.execute(Unknown Source)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
        at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
        at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)
        at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
解决方法:
1.建表的时候添加如下限制:ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
2.在my.cnf上修改如下:
------------------my.cnf------------------------------------------------------
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client]
default-character-set=utf8mb4
[mysql]
default-character-set = utf8mb4
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
 
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
 
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log-error=/var/log/mysqld.log
long_query_time=3
 
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
 
#log-slow-queries= /usr/local/mysql/log/slowquery.log
 ------------------------------------------------------------------------
重启mysql服务,service mysql stop;  service mysql start;问题解决。
造成这个问题的原因(网上找的):
mysql中规定utf8字符的最大字节数是3,但是某些unicode字符转成utf8编码之后有4个字节,导致出错。

MySql中报错:java.sql.SQLException: Incorrect string value: '\xF0\x9F\x90\xBB' for column的更多相关文章

  1. mysql 无法存储表情字符 java.sql.SQLException: Incorrect string value: '\xF0\x9F\x90\xBE",...' for column 'XXXX' at row 1

    1.变更字段类型 ALTER TABLE api_log MODIFY COLUMN remark longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_uni ...

  2. java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'nick' at row 1

    java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'nick' at row 1 mysql报错 ...

  3. 表情存储异常--mybatis抛出异常(java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for column 'name' at row 1)

    文章参考 https://blog.csdn.net/junsure2012/article/details/42171035 https://www.cnblogs.com/WangYunShuai ...

  4. java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\xB3' for column 'Content' at row 1

    在尝试将 emoji 表情符号 插入MySQL数据库时,遇到以下错误信息: ### The error occurred while setting parameters ### SQL: INSER ...

  5. mybatis抛出异常(java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for column 'name' at row 1)

    文章参考 https://blog.csdn.net/junsure2012/article/details/42171035 https://www.cnblogs.com/WangYunShuai ...

  6. Mysql插入数据报错java.sql.SQLException: Incorrect string value: '\xF0\x9F\x93\x8D\xE6\x88...'

    今天读取solr里面的数据,往mysql插入时报错, Incorrect string value: '\xF0\x9F\x93\x8D\xE8\x88...' for column 'title'  ...

  7. 【MySQL】java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\xB3' for column

    问题原因: 输入内容包含特殊字符,MySQL 中的列不支持. 解决方法 多数是修改 MySQL 的数据库和表结构,CHARSET 改为 utf8mb4,但本人测试还是不能传入 emoji. 后来在代码 ...

  8. 彻底解决:java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for column 'name' at row 1

    转载:https://blog.csdn.net/qq_31122833/article/details/83992085

  9. java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'name' at row 1

    我的错误案例: ,这个后台插不进去,就姓名那栏的中文编码问题. 遇到这个错误,应该是创建表的时候没有设置好编码,这个错误不用多想,我也试过在更改表那里设置编码,但还是不行,还是有残留 直接drop t ...

随机推荐

  1. 前端 CSS 盒子模型 目录

    CSS盒子模型介绍 padding border属性

  2. python 并发编程 多进程 互斥锁 目录

    python 并发编程 多进程 互斥锁 模拟抢票 互斥锁与join区别

  3. Julia出现错误ERROR: LoadError: syntax: try without catch or finally

    因项目要求进行机器学习数据可视化,要求尝试使用Julia,在此,记录下遇到的坑,仅为记录效果.后续陆续更新. 问题一:关于LightML库中的坑:ERROR: LoadError: syntax: t ...

  4. ubuntu14 文件夹添加/删除书签

    1. 打开文件管理,进入你要添加书签的目录 2. 把鼠标移到顶部选择“Bookmarks" 3. 这是文件管理左侧可以看到 4. 右键可以选择删除

  5. JDBC插入中文数据出现?号地解决问题

    1. 查看jdbc配置是否指定编码 Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/te ...

  6. go & Windows Service

    相关库 https://godoc.org/golang.org/x/sys/windows/svc https://github.com/kardianos/service https://gith ...

  7. 网络爬虫之HTTPClient

    HTTPClient官网:http://hc.apache.org/httpcomponents-client-4.5.x/quickstart.html 问题一:明明浏览器请求有数据,可使用HTTP ...

  8. vue项目1-pizza点餐系统11-设计menu页面

    菜单的页面设计是基于bootstrap实现的,主要用到的是table标签,其中获取data数据用到遍历. <template> <div class=""> ...

  9. Qt和其它GUI库的对比

    http://c.biancheng.net/view/3876.html 世界上的 GUI 库多如牛毛,有的跨平台,有的专属于某个操作系统:有的只有 UI 功能,有的还融合了网络通信.多媒体处理.数 ...

  10. 一、left

    一.left - right 就是遍历(以左边遍历,以右边遍历) inner join 就是求公共部分的结果集 left join 查询结果 right join结果 inner join 解决的办法 ...