This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes constraint violation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "constraint violation" Watch "constraint violation" New topic
Author

constraint violation

Grace Russo
Ranch Hand

Joined: Nov 08, 2010
Posts: 64
I am getting a constraint violation when inserting a record in a table.
So, I dropped the constraint in question since the intent is to be able to insert multiple records.

alter table table_name drop constraint constrain_Name

I look at the list of constraints for the table in question, the constraint has been dropped.

Still I cannot insert the record: same constraint violation comes up.

ANy ideas ?







Grace Russo
Ranch Hand

Joined: Nov 08, 2010
Posts: 64
dropping the corresponding index resolved the issue
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3700
    
    5

There are SQL commands you can perform to insert with the constraint disabled and then re-enable it after the insert. It's not generally a good practice, though, and I only use for bulk restoring of a database, ergo restoring 20 tables with thousands of records in a single script.


My Blog: Down Home Country Coding with Scott Selikoff
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: constraint violation
 
Similar Threads
Which one is faster
Unique Key Constraint Violated
Hibernate: How to delete mapping table
problem while inserting values
insert data into 2 tables using HQL