错误
### 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 配置文件 并打开
2.找到配置 default-character-set 和 character-set-server 配置
改为 default-character-set=utf8mb4
character-set-server=utf8mb4
保存文件
3.重启mysql,在任务管理器中,找到mysql 服务(输入M 回车 可找到服务 )右击重启服务,如果重启过程中,启动不起来,查看my.ini配置是否有问题
4. 将插入数据的 那张表,设置为 utf8mb4
更改数据库编码:ALTER DATABASE caitu99 CHARACTER SET utf8mb4
COLLATE utf8mb4_general_ci
; (没有这部操纵也可成功)
alter table 表名 convert to character set utf8mb4 collate utf8mb4_bin;
5.重新操作,插入数据 可看是否成功