问题描述:

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. EF Core 初始化数据库的两种方法。

    使用DbContextSeed初始化数据库 添加链接字符串 // This method gets called by the runtime. Use this method to add serv ...

  2. Node.js实战1:创建一个新的Node项目。

    你也许在猜专业的Node开发如何创建一个新项目. 有Npm在 ,这会非常简单. 虽然你可以创建一个JS文件,并执行:node file.js,但我建议你使用npm init来先创建一个node项目,这 ...

  3. Maven项目的常用jar包

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  4. Windows 运行时加载动态库

    下面是一个运行时加载nvcuda.dll,并检测当前驱动版本最大支持的CUDA版本的例子. #include "cuda.h" #include <stdio.h> # ...

  5. 通过QT查找Word中的关键字,并做高亮或删除操作

    最近由于项目需要,要用QT操作Word文档.具体的工作需求:在指定的Word文档(*.doc文件/*.docx文件)中查找关键字,找到后做高亮操作或者直接删除操作,然后另存为到别的目录(表示这个文件被 ...

  6. [Luogu 5465] [LOJ 6435] [PKUSC2018]星际穿越(倍增)

    [Luogu 5465] [LOJ 6435] [PKUSC2018]星际穿越(倍增) 题面 n个点的图,点i和[l[i],i)的所有点连双向边.每次询问(l,r,x)表示x到[l,r]的所有点的最短 ...

  7. anconda下安装opencv

    提示:如果你安装了python其它版本,或者在anaconda中创建了虚拟环境,应该先激活你的环境,然后再在命令窗口执行下面的操作 1.首先下载所需镜像文件: 我们需要上网站去下载我们需要的版本. 官 ...

  8. git命令?

    #文件及文件夹创建删除    mkdir  文件名称    (创建文件夹)    touch  文件名称    (创建文件)    rm -r  文件名称     (递归删除)    rm -rf 文 ...

  9. 6-1 如何读写csv数据

    >>> from urllib import urlretrieve >>> urlretrieve('http://table.finance.yahoo.com ...

  10. npm学习(十三)之npm命令

    npm:查看npm所有命令 自己写包可能用到的命令: npm adduser:注册 npm login:登录 npm whami:查看当前用户名 npm init:初始化包的信息 npm publis ...