Java and Jquery

Freelance Jobs

Wednesday, February 17, 2010

ORA-12899: value too large for column, Could not synchronize database state with session

I was getting below error when I was trying to insert the values in table:

[CAR] [2010-02-17 10:05:50,301] WARN [http-80-6] JDBCExceptionReporter.logExceptions(77) SQL Error: 12899, SQLState: 72000
[CAR] [2010-02-17 10:05:50,302] ERROR [http-80-6] JDBCExceptionReporter.logExceptions(78) ORA-12899: value too large for column "CARS"."CAR_ATTRIBUTE"."ATTR_VALUE" (actual: 2199, maximum: 2000)
[CAR] [2010-02-17 10:05:50,305] ERROR [http-80-6] AbstractFlushingEventListener.performExecutions(301) Could not synchronize database state 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:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
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:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:558) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:319)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy28.getAttributeValueProcessStatus(Unknown Source)
at com.belk.car.app.webapp.controller.DashBoardFormController.formBackingObject(DashBoardFormController.java:327)
.
.
.
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:735)
Caused by:
java.sql.BatchUpdateException: ORA-12899: value too large for column "CARS"."CAR_ATTRIBUTE"."ATTR_VALUE" (actual: 2199, maximum: 2000)
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:602)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9350)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:210)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 91 more


CAUSE:
Error clearly indicates that attribute value is larger than expected.
I was getting this error because the attribute I was trying to insert has value larger than the table attribute size.
In my case, the actual attribte value size was varchar(2000) however I was trying to insert more than that approx (2199)

Solution:
There could be two possible ways with which you can go with:
1. Update the table to increase the column size (In above case it could be varchar(2500)).
However, I dont suggest above option because in to change the table structure after insterting data is really very bad idea.
2. Change the attribute value which you are trying to insert and put proper size check and exception handeling.

The ultimate solution for such type of problem is prevention.
The table structure should be defined as per the requirement in the modeling phase of project.

No comments: