2012-05-04 202 views
0

從過去幾天我在ApacheTomcat日誌中得到這個奇怪的異常時,我在NetBeans IDE中運行Java struts2的Web應用程序。我找不出哪部分代碼導致了這個異常。休眠SQL異常

May 5, 2012 12:16:47 AM org.apache.catalina.core.StandardWrapperValve invoke 
SEVERE: Servlet.service() for servlet [default] in context with path [/latest-raisin] 
threw exception [org.hibernate.exception.GenericJDBCException: Could not execute JDBC 
batch update] with root cause 
java.sql.SQLException: Data truncated for column 'synsettype' at row 1 
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) 
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603) 
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535) 
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989) 
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150) 
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626) 
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119) 
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415) 
at 
com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1976) 
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449) 
at 

com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723) 
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70) 
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268) 
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114) 
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109) 
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244) 
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2541) 
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2494) 
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2821) 
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:113) 
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) 
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265) 
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185) 
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) 
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) 
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) 
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383) 
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133) 
at com.generalsentiment.management.filters.PersistenceSessionFilter.doFilter(PersistenceSessionFilter.java:48) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
at com.generalsentiment.management.filters.DisableUrlSessionFilter.doFilter(DisableUrlSessionFilter.java:91) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) 
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964) 
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) 
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) 
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
at java.lang.Thread.run(Thread.java:662) 

信息 - synsettype實際上是Synset表中的一列。

回答

5

我猜你試圖插入的數據太長了列。嘗試增加列的大小

+0

synsettype列的值爲varchar(200),它的值可以是「REGULAR」或「BOOLEAN」..根據業務規則沒有其他值.. –

+0

使用showSql = true顯示實際的插入語句,並調試值以查看是否沒有其他值或不必要的空格 – Bozho

+0

@Sangram Anand :)'java.sql.SQLException:第1行的列'synsettype'的數據被截斷'。顯然,數據截斷髮生。 – Lion