Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2010
    Posts
    25
    Rep Power
    0

    Post Error in JDBC batch update

    hi frnds,

    i am getting this error.see here i am using generator class as increment.if i use sequence i could solve this error.but what is difference in these two


    12:20:57 DEBUG (JDBCExceptionReporter.java.logExceptions():69) - Could not execute JDBC batch update [insert into TMCMS_TRF_PREF (TAX_TYPE_ID, PREF_TRF_TYPE, PREF_TRF_NAME, PREF_TRF_NAME_PT, PREF_DESC, PREF_DESC_PT, EXEMP_RATE, VALID_FROM, VALID_TO, PREF_STATUS, RATE_TYPE, AD_VALOREM_RATE, SPECIFIC_AMT, SPECIFIC_CURR, SPECIFIC_WEIGHT, SPECIFIC_MEASUREMENT, CREATED_DATE, CREATED_BY, UPDATED_DATE, UPDATED_BY, IS_SELECT_ALL, PREF_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
    java.sql.BatchUpdateException: ORA-00001: unique constraint (MCMSOWNER.PK_TMCMS_TRF_PREF_ID) violated

    at oracle.jdbc.driver.DatabaseError.throwBatchUpdateE xception(DatabaseError.java:566)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Batch(OraclePreparedStatement.java:9365)
    at oracle.jdbc.driver.OracleStatementWrapper.executeB atch(OracleStatementWrapper.java:210)
    at weblogic.jdbc.wrapper.PreparedStatement.executeBat ch(PreparedStatement.java:191)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch( BatchingBatcher.java:48)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(Ab stractBatcher.java:244)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:266)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:167)
    at org.hibernate.event.def.AbstractFlushingEventListe ner.performExecutions(AbstractFlushingEventListene r.java:298)
    at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:27)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:1004)
    at org.hibernate.impl.SessionImpl.managedFlush(Sessio nImpl.java:342)
    at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:136)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:655)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:709)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:678)
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.commitTransactionAfterReturning (TransactionAspectSupport.java:321)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:116)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy155.createPreferentialTariff(Unknown Source)
    at com.crimsonlogic.trade.mcms.tariff.jsfbean.Prefere ntialTariffBean.save(PreferentialTariffBean.java:3 74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:15 7)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpre ssionImpl.java:283)
    at com.sun.facelets.el.TagMethodExpression.invoke(Tag MethodExpression.java:68)
    at javax.faces.component.MethodBindingMethodExpressio nAdapter.invoke(MethodBindingMethodExpressionAdapt er.java:88)
    at com.sun.faces.application.ActionListenerImpl.proce ssAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UIComman d.java:387)
    at org.ajax4jsf.component.AjaxViewRoot.processEvents( AjaxViewRoot.java:329)
    at org.ajax4jsf.component.AjaxViewRoot.broadcastEvent sForPhase(AjaxViewRoot.java:304)
    at org.ajax4jsf.component.AjaxViewRoot.processPhase(A jaxViewRoot.java:261)
    at org.ajax4jsf.component.AjaxViewRoot.processApplica tion(AjaxViewRoot.java:474)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:82)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:1 00)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(Life cycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServl et.java:265)
    at weblogic.servlet.internal.StubSecurityHelper$Servl etServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invok eServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute( ServletStubImpl.java:292)
    at weblogic.servlet.internal.TailFilter.doFilter(Tail Filter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:42)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(Base XMLFilter.java:206)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseF ilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHa ndleRequest(BaseFilter.java:388)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter .java:515)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:42)
    at com.crimsonlogic.trade.common.util.PageFiltering.d oFilter(PageFiltering.java:213)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:42)
    at org.springframework.orm.hibernate3.support.OpenSes sionInViewFilter.doFilterInternal(OpenSessionInVie wFilter.java:198)
    at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:42)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter. doFilter(ExtensionsFilter.java:285)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:42)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter. doFilter(ExtensionsFilter.java:341)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:42)
    at weblogic.servlet.internal.RequestEventsFilter.doFi lter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:42)
    at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationAction.run(WebAppServletContext.java :3496)
    at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Un known Source)
    at weblogic.servlet.internal.WebAppServletContext.sec uredExecute(WebAppServletContext.java:2180)
    at weblogic.servlet.internal.WebAppServletContext.exe cute(WebAppServletContext.java:2086)
    at weblogic.servlet.internal.ServletRequestImpl.run(S ervletRequestImpl.java:1406)
    at weblogic.work.ExecuteThread.execute(ExecuteThread. java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java :173)
    12:20:57 WARN (JDBCExceptionReporter.java.logExceptions():77) - SQL Error: 1, SQLState: 23000
    12:20:57 ERROR (JDBCExceptionReporter.java.logExceptions():78) - ORA-00001: unique constraint (MCMSOWNER.PK_TMCMS_TRF_PREF_ID) violated

    12:20:57 WARN (JDBCExceptionReporter.java.logExceptions():77) - SQL Error: 1, SQLState: 23000
    12:20:57 ERROR (JDBCExceptionReporter.java.logExceptions():78) - ORA-00001: unique constraint (MCMSOWNER.PK_TMCMS_TRF_PREF_ID) violated

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    In that there are probably multiple threads making calls to this "generator" (and probably their own instances of it at that) and so more than one thread attempts to use the same key. servlets/jsp are inherently threaded.

  3. #3
    Join Date
    Jun 2010
    Posts
    25
    Rep Power
    0

    Post Sequence

    thanks,

    if we use sequence means is it allow multiple thread calls?
    Thanks&Regards,
    Muralikrishna K

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    I would assume so.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Oracle sequences (sort of) lock on each request for a new number, so are inherently thread safe. Be a bit useless if they weren't.

    They're not a table (hence the "sort of" above). More a pool of numbers, so a rollback will not return a number to the pool.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    You really took it personally didn't you?
    Dear god I hope I never have to work with you...the first code review would be a real event.

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    You've got look at his history (and for today, mine although you'll be doing both by looking at his). This is nothing. He was almost civil.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    But he got an A...with merit!
    He said so...

  9. #9
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. Replies: 23
    Last Post: 03-20-2010, 09:24 AM
  2. PreparedStatement using batch update
    By swati.jyoti in forum New To Java
    Replies: 3
    Last Post: 06-02-2009, 10:05 AM
  3. Mysql/JDBC update query problem
    By thelinuxguy in forum Advanced Java
    Replies: 3
    Last Post: 02-11-2009, 09:56 PM
  4. Replies: 0
    Last Post: 04-01-2008, 10:17 AM
  5. Replies: 0
    Last Post: 09-28-2007, 12:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •