Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

synchronize database state with session  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am getting this exception when i try to do insertion to DB using Hibernate


The exception is as follows:
(JDBCExceptionReporter.java:72) - Duplicate key or integrity constraint violation message from server: "Duplicate entry '10.50.34.36-Authentication Failure' for key 'PRIMARY'"
ERROR [2011-09-14 01:17:45] [Thread-11] (AbstractFlushingEventListener.java:299) - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
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:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1007)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:354)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.tel.Database.DBAlarmCRUD.insert(NMSDBAlarmCRUD.java:110)
at com.tel.Fault.FaultEventHandler.handleEvent(NMSFaultEventHandler.java:100)
at com.tel.Fault.FaultTrapHandler.handleTrap(NMSFaultTrapHandler.java:62)
at com.tel.Fault.FaultTrapReceiver.run(NMSFaultTrapReceiver.java:204)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Duplicate entry '10.50.34.36-Authentication Failure' for key 'PRIMARY'"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1492)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)



And in the insert method at this line : transaction.commit(); the exception is shown.



Thanks in advance,

 
Bartender
Posts: 2651
18
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Nami!


This is the direct cause of your problem:
Caused by: java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Duplicate entry '10.50.34.36-Authentication Failure' for key 'PRIMARY'"


You, or your software, is trying to put the text '10.50.34.36-Authentication Failure' in a database field that requires that all values are unique, and that field already contains that text in another record. You are violating a primary key constraint.

 
nami shekar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jan Cumps,
Thank you for your reply

Say suppose i have hundred data to be inserted into DB
50 or 60 may get inserted without any probelm, and later i get this problem.
And few times without any problem the code works fine. Why is it so?
 
Jan Cumps
Bartender
Posts: 2651
18
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I moved your thread to our Object Relational Mapping forum. That is the right place for Hibernate questions.
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!