File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException" Watch "com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException" New topic
Author

com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException

raghu tammina
Ranch Hand

Joined: Jul 11, 2012
Posts: 59
Hi ,

I am using struts with myecllipse, i am getting the exception com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException

my source code is

I created a table in mysql as follows

CREATE TABLE `tab_ats_backlogymapper` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`lable` varchar(100) NOT NULL,
`col_num` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`,`lable`),
UNIQUE KEY `Index_2` (`col_num`)
)
Help me how to handle it?

Stacktrace: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry '2' for key 'Index_2'
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

Moving this to the JDBC forum for you.


[How To Ask Questions][Read before you PM me]
Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 186
It appears you are trying to insert a row with col_num value of 2 into the table which already contains a row with col_num value of 2, and you have defined a unique constraint over that column which this query is violating. Either remove the constraint, or make sure you are not trying to enter the same value more than once into a column which is constrained.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException
 
Similar Threads
How to store images into mysql using jsf and java coding
facing a problem
Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException
Could not create entity com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException