16:01:41,060  WARN JDBCExceptionReporter:77 - SQL Error: 1366, SQLState: HY000
16:01:41,060 ERROR JDBCExceptionReporter:78 - Incorrect string value: '\xE4\xBD\xA0\xE5\xA5\xBD' for column 'name' at row 1
16:01:41,060 ERROR AbstractFlushingEventListener:301 - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1001)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:339)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.guoxin.model.Dog.main(Dog.java:24)
Caused by: java.sql.BatchUpdateException: Incorrect string value: '\xE4\xBD\xA0\xE5\xA5\xBD' for column 'name' at row 1
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1666)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1082)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247)
... 8 more
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1001)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:339)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.guoxin.model.Dog.main(Dog.java:24)
Caused by: java.sql.BatchUpdateException: Incorrect string value: '\xE4\xBD\xA0\xE5\xA5\xBD' for column 'name' at row 1
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1666)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1082)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247)
... 8 more检查了语句都没什么问题!
<hibernate-configuration>    <session-factory>
        <property name="hbm2ddl.auto">update</property>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/cf?characterEncoding=utf-8</property>
        <property name="connection.username">root</property>
        <property name="connection.password">1111</property>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="myeclipse.connection.profile">localhost</property>
   <mapping class="com.guoxin.common.DogManager"/>
    </session-factory></hibernate-configuration>
这里是关于hibernate的配置!我将上面的中文转化删除掉就可以存入数据库而不报错!但是存入的中文数据是乱码!

解决方案 »

  1.   

    报错原因:不正确的String赋值到了表的NAME字段里面去了。bebug一下看看,生成的sql是什么样的,能否执行。
      

  2.   

    jdbc:mysql://localhost:3306/cf?useUnicode=true&characterEncoding=UTF-8,还有就是看看到底是你页面传值过来已经是乱码了,还是存入数据库的时候才是乱码
      

  3.   

         你红色的部分加上去会报错!~我这里是用的是。CFG.XML  不是。properties 页面传值是中文,存入数据库就是乱码了!~~
      

  4.   

    那你就
    <property name="connection.url">jdbc:mysql://localhost:3306/cf</property>
    <property name="Connection.useUnicode">true</property> 
    <property name="connection.characterEncoding">UTF-8</property> 
      

  5.   

    你去看看是不是你添加的某列的长度不够,转码过后长度增加,还有就是,你为什么不用GBK?而是UTF-8,我估计转码会有问题哦
      

  6.   

      GBK也试过了 也是报同样的错误。长度设置是255默认的~~ 很谢谢你一直回复我的帖子!!
      

  7.   

      MYSQL的驱动是5.几的!~~~~嘿嘿!~~~~