正如标题所说,我正在使用hibernate orm,每当我试图用č 或者ć 在它的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
1条答案
按热度按时间k3bvogb11#
抱歉,伙计们,这是个愚蠢的疏忽。我在hibernate cfg文件中指定了utf8,但在创建数据库时忘记了这样做。