• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Could not execute JDBC batch update

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
When I try to add a record, this is the exception I am getting.

I am using Hibernate and struts

"net.sf.hibernate.JDBCException: Could not execute JDBC batch update"

Anyone pls help to find out the reason a solution to correct it

Thanks

Vidya
 
Ranch Hand
Posts: 293
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would recommend setting Hibernate to show the SQL that is is producing. This may give you an idea what is going wrong.
 
vidya archana
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the case of insertion do I need to generate the query, I am using the save() function given by the Session Class. Also the values in the object are coming correctly also.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vidya archana:
In the case of insertion do I need to generate the query, I am using the save() function given by the Session Class. Also the values in the object are coming correctly also.


No, you don't need to generate any SQL, but Hibernate does. Set Hibernate to show the SQL it is producing as Dave recommends and you will have an easier job figuring out what is wrong.
 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"net.sf.hibernate.JDBCException: Could not execute JDBC batch update"



This message is really generic and just says that the update failed. You need to determine the root cause.

The exception probably had another exception nested inside of it. The nested exception would print a message and stack trace right below the outer one and would indicate the cause of the exception.

You could have several levels of nested exceptions, but if you scan to the bottom of the list you will see the root cause exception. What does it say?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem you faced is being displayed as top level message.

Like :
Inserting Record
Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?)
Could not execute JDBC batch updateDONE... !! END.

This problem is due to constraint violation. You are trying to save recoed which might be violating the constraints like Primary Key in existing records.

 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You might need to increment the setId value to next or greater value like
contact.setId(11);
 
Ranch Hand
Posts: 80
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Annotations Use @GeneratedValue

with strategy=GenerationType.AUTO
 
And then the flying monkeys attacked. My only defense was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic