gpt4 book ai didi

java - 无法存储包含特殊字符的消息

转载 作者:可可西里 更新时间:2023-11-01 08:37:20 26 4
gpt4 key购买 nike

我正在尝试将以下推文存储到 MySQL 数据库中,但失败并出现以下异常。我如何解决它?任何帮助表示赞赏。我正在使用 utf8 字符集数据库,我认为消息中的 !??? 在这里有问题。

tweet=I'm forbidden by a ride @ USS due to my height, I'm suppose to sit in the mid, incase there's an accident, but I still love my height!???

Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'message' at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2427)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2345)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2330)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)

最佳答案

在您的驱动程序 url 路径中使用以下参数

jdbc:mysql://<host>:<port>/<db>?useUnicode=true&characterEncoding=UTF-8

关于java - 无法存储包含特殊字符的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8603825/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com