一: Hibernate: select max(id) from people
Hibernate: insert into people (username, password, telphone, gender, graduation, birthday, marryTime, file, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
org.hibernate.exception.DataException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:100)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
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:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at com.shengsiyuan.hibernate.HibernateTest.main(HibernateTest.java:69)
Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'file' at row 1
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2028)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1451)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 8 more
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'file' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3607)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2427)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1980)
... 11 more
主要是编码格式不对:
mySql错误:Data truncation: Data too long for column :这个问题是字符集编码格式问题,修改mysql 安装文件下的my.ini 文件,[mysql] 下面default-character-set=UTF8 修改成utf-8或者gbk,此文件中还有一处要改的 # created and no character set is define 下面default-character-set=UTF8 然后在的data目录下找到相应数据库文件 找到db.opt 文件 default-character-set=UTF8 default-collation=UTF8_swedish_ci 这2行文字都要改,这些都改了要是还不行的话,再查看你表的编码和表中字段的编码格式:在表上点击右键——表讯息——DDL 可以看到表和字段的编码格式,要是跟你配置文件中的不一致的话修改就OK了,修改方法:在表上点击右键——设计表——选项——字符集 ,然后点击你表中的每个字符串字段,查看下面的字符集编码是否一致,所有工作都做了肯定就好了。 http://yixinshan.taobao.com
二:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2882)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
at java.lang.StringBuffer.append(StringBuffer.java:224)
at org.hibernate.type.AbstractBynaryType.toString(AbstractBynaryType.java:164)
at org.hibernate.type.NullableType.toLoggableString(NullableType.java:239)
at org.hibernate.pretty.Printer.toString(Printer.java:76)
at org.hibernate.pretty.Printer.toString(Printer.java:113)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:120)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:49)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at com.shengsiyuan.hibernate.HibernateTest.main(HibernateTest.java:69)
是保存的文件过于大
三:
每次发送的文件过大:
com.mysql.jdbc.PacketTooBigException:packa for query is too large(213242>43243)
此时可以在C:\Program Files\MySQL\MySQL Server 5.5目录下的my.ini文件中最后加入
max_allowed_package=2300975这样一行文字
这个值根据实际情况而定