Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException

 
raghu tammina
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the JDBC forum for you.
 
Emanuel Kadziela
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic