This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Duplicate Key Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Duplicate Key Exception" Watch "Duplicate Key Exception" New topic
Author

Duplicate Key Exception

ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76
Hi,

I have a column which is Unique, when I try to enter duplicate values, it gives me duplicate key exception. How to catch this exception.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61066
    
  66

Moved to Java in General (beginner)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Can you please elaborate? Where are you storing this unique "column"? Where are you "entering" it? What code causes the exception?

In general, you use a try...catch() clause to catch an exception:

I suggest you find a beginning Java text. Any text worth its salt will have at least an introduction to exception handling that will provide more details than I have given here. Alternatively, you chould check out the exception handling section in the Java Tutorial (see the link in my sig).

Layne


Java API Documentation
The Java Tutorial
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Duplicate Key Exception