用Struts+DAO+Hibernate+MySql写的程序发生:Could not execut

xiaoxiao2026-03-16  7

错误提示: Could not execute JDBC batch update Exception in thread "main" org.hibernate.exception.DataException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at yubiao.zyb.Demo01.impl.PersonDAOImpl.insert(PersonDAOImpl.java:33) at yubiao.zyb.Demo01.test.PersonTest.main(PersonTest.java:29) Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'sex' at row 1 at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:665) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195) ... 9 more [size=xx-small][color=red]这个就有很多可能是: 比如你传入的字符串长度过长,查看数据库中字段的长度,java类里面属性的类型和Hibernate的配置文件.hbm.xml里面声明不一致都可以造成以上错误。 [/color][/size]
转载请注明原文地址: https://www.6miu.com/read-5046008.html

最新回复(0)