gpt4 book ai didi

mysql - Hibernate mysql utf8配置

转载 作者:行者123 更新时间:2023-11-29 20:10:08 25 4
gpt4 key购买 nike

我使用的是hibernate 4.1.4,mysql连接器是5.1.6。 Hibernate 和 tomcat server.xml 连接器配置如下。当我尝试保存时,我遇到了异常。有什么问题吗?

Caused by: java.sql.SQLException: Incorrect string value: '\xC5\x9Fekk\xC3...'

<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
URIEncoding="UTF-8" />

<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/*****?UseUnicode=true&amp;characterEncoding=utf8</property>
<property name="hibernate.connection.CharSet">utf8</property>
<property name="hibernate.connection.characterEncoding">utf8</property>
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.username">****</property>
<property name="hibernate.connection.password">***</property>
<property name="hibernate.hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>

最佳答案

十六进制C58F是utf8/utf8mb4编码中的ş

在Hibernate配置中,我认为它是用破折号拼写的:UTF-8

另请参阅https://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-db-configuration-hibernate.html

关于mysql - Hibernate mysql utf8配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40192378/

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