File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to control the User from inserting the same EIN(unique no. in db) and Primary Key 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 » Frameworks » Struts
Bookmark "How to control the User from inserting the same EIN(unique no. in db) and Primary Key violation?" Watch "How to control the User from inserting the same EIN(unique no. in db) and Primary Key violation?" New topic
Author

How to control the User from inserting the same EIN(unique no. in db) and Primary Key violation?

Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
How to use the error handling properly so that i can avoid the primary key violation ?

Thanks in advance


Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
Ranveer K Kumar
Ranch Hand

Joined: Sep 13, 2009
Posts: 64
Vinod Vijay wrote:How to use the error handling properly so that i can avoid the primary key violation ?

Thanks in advance


1) You can set primary key as database/server side. which can be auto generated so user can not enter the duplicate value. (can be display on the form as read only field)
2) You can check the user entered value on server for duplication before inserting the record..
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

What is EIN ? Is it some kind of ID ? then ID is supposed to be created by DB.
If its anything other attribute than ID, then first you need to find out any row with that same EIN, if not present, enter one.

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
 
 
subject: How to control the User from inserting the same EIN(unique no. in db) and Primary Key violation?
 
Similar Threads
Exception while trying to add a new user to the database
Strange Duplicate Key Exception while working with WAS 6 and DB2
What is the difference between executeUpdate and execute?
When does the hibernate query commit?
Primary key and update method strange issue