我使用的是hibernate 4.1.4,mysql連接器是5.1.6。 Hibernate和tomcat server.xml連接器配置如下。當我嘗試保存時,我得到了這個異常。什麼是錯的?休眠mysql utf8配置
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&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>
什麼是*****值? – Mahi
這就是我的數據庫名稱,用戶名和密碼。機智就是沒問題@Mahi – nikinci
嘗試utf-8連接url – Mahi