java string 连接 039,java 插入数据时报错Incorrect string value: '\xF0\x9F\x88\x9A' for column &#039...

"本文介绍了在插入含有特殊字符(如表情符号'xF0x9Fx88x9A')到MySQL数据库时遇到的错误,提供了通过修改my.ini配置、数据库编码和表字符集设置来解决此类问题的步骤。重点在于如何处理 Incorrect string value 错误和字符集转换。"
摘要由CSDN通过智能技术生成

错误

### SQL: INSERT INTO SAMPLEINF (SAMPLEID, NAME, GENEDER, BIRTHDAY, SAMPLETYPE, NATION, INSPECTIONUNIT, INSPECTIONDOCTOR, INSPECTIONID, RECEIVEDDAY, MEIDCALHISTORY, FAMILYHISTORY, PRO_ID, CREATE_TIME, CREATE_BY, C_CODE, C_ID, AGE, ID_CARD, DIAGNOSIS, GENE, PHONE, C_NO, ADDRESS, C_TYPE, RELATIONSHIP, PROJECT_NAME, PRODUCT_ID, PRODUCT_NAME, DETECTION_TECHNOLOGY, DEPARTMENT, HOSPITALIZATION_NO, BED_NO, CASE_NO, NATIVE_PLACE, OCCUPATION, EDUCATION, DETECTION_REASON, MARITAL_STATUS, HEIGHT, WEIGHT, GESTATIONAL_WEEKS, EMAIL, PERSONAL_HISTORY, PERSONAL_GROWTH_HISTORY, ALCOHOL_DRUG_HISTORY, HAZARDOUS_CHEMICALS_HISTORY, ISCLINICAL, ISFREE, FREETYPE, REPORT_RECIPIENTS, SALESPERSON, REMARK, COMPLAINS, BELONG_USER_ID, SAMPLE_POSITION, SAMPLE_TYPE, CANCER_TYPE, RECEIVE_DATE, CONTROL_ID, CONTROL_TYPE, LAST_DATE, EXPERIMENT_NOTES, SENT_DATE, SENT_PERSON, THRESHOLD,TUMORMETASTASIS,CANCER_SMALL_TYPE,CANCERSTAGING,diagnosis_id,patient_id,primary_id, collection_date,isStop,lastUpdateTime,lastUpdateUser,sampleStorageTime,reportSendingTime,reportReviewTime,reportSecondReviewTime,reportUploadFileName) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "900004", sysDate(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?, ?,?,?,?,?,? )

### Cause: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x88\x9A' for column 'personal_history' at row 1

; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1366]; Incorrect string value: '\xF0\x9F\x88\x9A' for column 'personal_history' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xF0\x9F\x88\x9A' for column 'personal_history' at row 1

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)

解决方案:

1.打开mysql 安装文件,找到my.ini  配置文件 并打开

5a97b1d01880b46e261f6a5f41f46c63.png

2.找到配置   default-character-set  和 character-set-server 配置

改为  default-character-set=utf8mb4

character-set-server=utf8mb4

保存文件

3.重启mysql,在任务管理器中,找到mysql 服务(输入M 回车 可找到服务 )右击重启服务,如果重启过程中,启动不起来,查看my.ini配置是否有问题

ccfadbaa8f30ee31941be0a36e6d18a5.png

4. 将插入数据的 那张表,设置为   utf8mb4

更改数据库编码:ALTER DATABASE caitu99 CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;   (没有这部操纵也可成功)

alter table 表名 convert to character set utf8mb4 collate utf8mb4_bin;

5.重新操作,插入数据 可看是否成功

标签:Incorrect,set,java,utf8mb4,character,TYPE,ID,row

来源: https://www.cnblogs.com/xiaochen-Cao/p/14400052.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值