java.sql.SQLException: Incorrect string value: '\xE6\x88\x91\xE7\x9A\x84...' for column 'groupName'
java.sql.SQLException: Incorrect string value: '\xE6\x88\x91\xE7\x9A\x84...' for column 'groupName' at row 1
甚是纠结,我原本以为应该是以下问题之一:
(1).创建数据库的时候数据编码设置错误
(2).连接数据库的时候数据编码设置错误
对于(1),我删除来原来的数据库,重新创建一个新的数据库在设置编码时,我的设置如下:
character set:utf8 -- UTF-8 Unicode
collation:utf8_general_ci
发现这样设置之后,不能解决这个问题。
对于(2),我将连接语句写为:
"jdbc:mysql://" + ip + ":3306/users?useUnicode=true&characterEncoding=utf8"
但问题仍然没有解决。
又仔细观察我写的程序,发现在程序中有向数据库中创建表的操作,语句如下:
"create table friendsList (qq varchar(7) primary key,remark varchar(20),groupName varchar(20)) ;"
这样,问题变得明朗了,原来创建每张表的时候都必须设置数据编码方式,改后的语句如下:
"create table friendsList (qq varchar(7) primary key,remark varchar(20),groupName varchar(20)) charset utf8 collate utf8_general_ci;"
总结一下,引起本文章标题这样的问题的原因有以下几个:
(1).创建数据库的时候数据编码设置错误
(2).连接数据库的时候数据编码设置错误
(3).创建表的时候数据编码设置错误
java.sql.SQLException: Incorrect string value: '\xE6\x88\x91\xE7\x9A\x84...' for column 'groupName'的更多相关文章
- 解决java.sql.SQLException: Incorrect string value: '\xE6\x88\x91\xE7\x9A\x84...' for column 'groupName'
今天使用mysql,用java程序往mysql中写数据,出现如下错误: Caused by: java.sql.SQLException: Incorrect string value: '\xD3\ ...
- mysql插入报错:java.sql.SQLException: Incorrect string value: '\xE6\x9D\xAD\xE5\xB7\x9E...' for column 'address' at row 1
界面报错: 日志报错: java.sql.SQLException: Incorrect at com.mysql.cj.jdbc.exceptions.SQLError.createSQLExcep ...
- java.sql.SQLException: Incorrect string value: '\xF0\x9F\x91\x88\xE6\x88...' for column 'content' at row 1
往MySQL插入数据时,报错如下 java.sql.SQLException: Incorrect at com.mysql.cj.jdbc.exceptions.SQLError.createSQL ...
- MySQL报错:Cause: java.sql.SQLException: Incorrect string value: '\xE6\x9D\xA8","...' for column 'obj_value' at row 1
1.插入MySQL表时,报错:Cause: java.sql.SQLException: Incorrect string value: '\xE6\x9D\xA8","...' ...
- mysql 保存emoji时报,数据库报错:Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x82\xF0\x9F...' for column 'review' at row 1
错误原因:我们可以看到错误提示中的字符0xF0 0x9F 0x98 0x84 ,这对应UTF-8编码格式中的4字节编码(UTF-8编码规范).正常的汉字一般不会超过3个字节,为什么为出现4个字节呢?实 ...
- java.sql.SQLException: Incorrect string value: '\xE5\xBC\xA0\xE9\x9B\xB7' for column 'content' at row 1
这个问题主要是由于该字段及腹肌编码不正确导致的,一般新建的表如果没设置就会是latin1字符集需要将表改为utf8字符集,再将报错的列的字符集改为utf8即可,修改命令如下所示: ALTER TABL ...
- jeesite导入数据库错误:java.sql.SQLException: Incorrect string value: '\xE4\xB8\xAD\xE5\x9B\xBD' for column 'name' at row 1问题解决
如果使用mvn antrun:run -Pinit-db进行数据库导入导致出现如下错误: 解决方法: 这个是由于新建数据库没有选择默认字符集导致的,只要选择utf-8即可.
- org.springframework.jdbc.UncategorizedSQLException: ### Error updating database. Cause: java.sql.SQLException: Incorrect string value: '\xE2\x80\x8B\xE2\x80\x8B...' for column 'pro_backgroud' at row
如果你在mysql数据库中,将所有的表的编码格式设置成为utf-8之后还是不行,那就试试这个吧:ALTER TABLE your_database_name.your_table CONVERT TO ...
- 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 ...
随机推荐
- SQL Server知识详解
1.SET NOCOUNT ON的作用: 作用:阻止在结果集中返回显示受T-SQL语句或则usp影响的行计数信息. 语法:SET NOCOUNT {ON | OFF} 详解:当SET ONCOUNT ...
- 1118 Birds in Forest (25 分)
Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in ...
- html上传多图并预览
涉及知识:base64处理图片,ajax,js,thinkphp 效果图: 代码实现: html: <!DOCTYPE html> <html> <head> &l ...
- C++继承详解:共有(public)继承,私有(private)继承,保护(protected)继承
公有继承(public).私有继承(private).保护继承(protected)是常用的三种继承方式. 1. 公有继承(public) 公有继承的特点是基类的公有成员和保护成员作为派生类的成员时, ...
- thinkphp5.0 cache数据缓存机制
use think\cache; public function index(){ //Cache::get('name')获取缓存,如果name值不存在则返回false: if (Cache::ge ...
- 存储-InfluxDB
1 TSDB influxDB是一个time series时间序列数据库. 在监控系统的开发中,大体分为采集-存储-可视化三个大类.监控指标有很显著的时间特征数据,一般采用TSDB存储. 在TSDB中 ...
- Tinghua Data Mining 5
ID3 ID3算法倾向于分的很细的变量 C4.5加入分母为惩罚量
- 利用arguments对象在javaScript中实现重载(overload)
一些概念: 重载(overload): 什么是: 相同函数名,不同参数列表的多个函数,在调用时,可根据传入参数的不同,自动选择对应的函数调用! 为什么: 减轻调用者的负担,一个函数名,可执行多种操作 ...
- [软件工程基础]2017.10.30 第三次 Scrum 会议
决议 游心与李煦通沟通生成报告脚本问题,并调试相应代码 李煦通部署服务器,并做一定安全检查 石奇川设计实验流程和题库前端页面 王嘉睿爵测试网站基本流程,提出关于用户体验方面的建议 刘子渊阅读代码,为机 ...
- python 全局变量 局部变量
##全局变量,局部变量#在函数内部可以调用全局变量,不能随意改变全局变量#若要在函数内部改变全局变量,需用关键字global #代码中全局变量都大写,局部变量都小写(非必须,一种规范) P = &qu ...