aspose file tools*
The moose likes Object Relational Mapping and the fly likes Could not execute JDBC batch update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Could not execute JDBC batch update" Watch "Could not execute JDBC batch update" New topic
Author

Could not execute JDBC batch update

vidya archana
Ranch Hand

Joined: Oct 29, 2002
Posts: 36
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
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 293

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

Joined: Oct 29, 2002
Posts: 36
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.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
"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?
Ashok Pokharkar
Greenhorn

Joined: Sep 20, 2009
Posts: 1
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.

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
Hi,

You might need to increment the setId value to next or greater value like
contact.setId(11);
Shahir Deo
Ranch Hand

Joined: Mar 19, 2013
Posts: 80

In Annotations Use @GeneratedValue

with strategy=GenerationType.AUTO

Knowledge enlivens the soul.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Could not execute JDBC batch update