正如标题所说,我正在使用Hibernate ORM,每当我尝试用Č或save保存某些内容时,hibernate抛出“无法执行查询”错误。我使用utf8,Š,Ž,Đ字符工作得很好。我迷路了......这是cfg文件:
<property name="connection.url">jdbc:mysql://localhost:3306/eventi_orm</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.CharSet">utf8</property>
<property name="hibernate.connection.characterEncoding">utf8</property>
<property name="hibernate.connection.useUnicode">true</property>
<property name="show_sql">true</property>
<property name="format_sql">false</property>
这是输出:
Exception in thread "AWT-EventQueue-0" org.hibernate.exception.DataException: could not execute statement
...
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect string value: '\xC4\x87' for column 'name' at row 1
答案 0 :(得分:0)