关于java.sql.SQLException: Incorrect string value的解决方法
来源:互联网 发布:什么是贵族气质知乎 编辑:程序博客网 时间:2024/06/05 13:33
近期在做业务测试时,出现java.sql.SQLException: Incorrect string value,其具体信息如下:
Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x81\xF0\x9F...' for column 'content' at row 1at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4232)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)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:2838)at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1307)at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:44)at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:69)at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:48)at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105)at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71)at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152)at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:141)at sun.reflect.GeneratedMethodAccessor274.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:606)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)通过网上查找资料,发现,在某些字符转化为Unicode编码时占用4个字符,而一般情况下Mysql默认的UTF8编码所允许的单个编码占用的长度为3个字节,每种编码的最大占用长度可用过命令为:
show character set
进行查询,查询的实例结果如下:
因此只要将该表的编码改为最大允许长度为4的编码格式即可;
0 0
- 关于java.sql.SQLException: Incorrect string value的解决方法
- java.sql.SQLException: Incorrect string value
- java.sql.SQLException: Incorrect string value
- java.sql.SQLException: Incorrect string value:
- mysql的Caused by: java.sql.SQLException: Incorrect string value
- 中文为”???“的解决方法,和Hibernate:Caused by: java.sql.SQLException: Incorrect string value: '\xE8\x8F异常
- 关于mysql的java.sql.SQLException: Incorrect string value: '\xF0\x9F\x91\xBD\xF0\x9F…'问题
- java.sql.SQLException: Incorrect string value: 插入中文报错
- MySQL utf8转utf8mb4(java.sql.SQLException: Incorrect string value...)
- java.sql.SQLException: Incorrect string value: '\xF0\x9F\x90\x94"
- 解决emoji表情的数据库存取问题:Cause: java.sql.SQLException: Incorrect string value
- mysql的utf8mb4编码以及java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' 问题的处理
- 解决java插入mysql时出现java.sql.SQLException: Incorrect string value: '\xF0...'问题
- Error: java.io.IOException: java.sql.SQLException: Incorrect string value: '\xE4\xBA\xBA ' for colum
- java.sql.SQLException: Incorrect string value: '\xE5\x90\x88\xE8\xAE\xA1' for column
- Exception in thread "main" java.sql.SQLException: Incorrect string value: '\xF0\xA2\x9C\xB6\xE2\x80.
- java.sql.SQLException: Incorrect string value: '\xE6\x88\x91\xE7\x9A\x84...' for column 'groupName'
- Caused by: java.sql.SQLException: Incorrect string value: '\xE5\x91\xA8\xE6\ --异常
- 【SHELL】使用ps如何准确地打印出某个用户的进程
- php错误屏蔽
- symfony 加载插件方法
- ArcGIS开发权威指南 上架
- 5个数求最值
- 关于java.sql.SQLException: Incorrect string value的解决方法
- InstallScript的事件
- 【大渣】【DP+单调队列优化】布丁
- LeetCode--Delete Node in a Linked List
- Java synchronized详解
- 电缆快速检测系统硬件设计
- MySQL导出数据到txt
- "undefined reference to" 问题解决方法
- APR 池