aspose file tools*
The moose likes JDBC and the fly likes Checking for already existing data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Checking for already existing data" Watch "Checking for already existing data" New topic
Author

Checking for already existing data

Patrick Mugabe
Ranch Hand

Joined: Jan 08, 2002
Posts: 132
Hi Ranchers,
I have a simple form which takes in Student Details such as name, surname, address, etc and saves the data to a database. The studentID is automatically generated.
I would want to do a check to see whether the typed in name and surname already exists because there is a possibility of entering the same details twice since studentID is an autoNumber.
How can I check before updating.
Please assist.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You just have to check/search your database for the firstname & lastname combination before making the entry.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
But you shouldn't only check for first and last name. Cause it is possibility that two people have the same name. Better check for something
unique like the Student ID. Or take additional fields to check for uniqueness.
Nagendra Prasad
Ranch Hand

Joined: Jul 11, 2002
Posts: 219
I think this is referred to as the logical key for that table.
This is generally a set (or single) column in a table which also needs to be unique apart for the primary key. (Which is most cases is a sequence generated integer).
Define a logical key for your student table and you would know what to search on!


Best Regards,<br />Nagendra Prasad.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Checking for already existing data