Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MySQLIntegrityConstraintViolationException: Duplicate entry

Zulfi KhanFeb 18 2017 — edited Feb 26 2017

Hi,

I have created a table with id as a primary key.

When I am entering same id again & I am getting following errors:

MySQLIntegrityConstraintViolationException: Duplicate entry

I am catching SQLException:

catch(SQLException se){

      //Handle errors for JDBC

      JOptionPane.showMessageDialog(null, "Testing");

      se.printStackTrace();

   }

The control enters into catch block &

Its printing "Testing". So exception is caught. So why i am getting this error. Some body please guide me how to handle this error.

Zulfi.

This post has been answered by Zulfi Khan on Feb 26 2017
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 26 2017
Added on Feb 18 2017
6 comments
14,599 views