Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to stop entering data

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have created an interface which accepts the details of a person and stores it in database it also stores the id. Now what i need is if the details are entered more than 3 times then i should get a message that "U cant enter any more". So please some one give me an idea please its urgent.
 
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Entered where? In the database? Or in the user interface?

If it is in the database, you first have to perform a query to find out how many records already match your criteria:

If that returns a number too high (like 3 already) then deny the entering.
[ June 06, 2008: Message edited by: Rob Prime ]
 
Marshal
Posts: 65100
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by adeeb alexander:
please its urgent.

Ease Up. And I see Rob has beaten me to it with a useful answer.
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya i want to enter data into database with the help of gui
and as you said that i have to write a query but how to write it. How can we compare the rows. Can you please tell me
 
Rob Spoor
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends what fields you have and which ones are relevant for the uniqueness.

Suppose you have a first and last name, and these can only occur 3 times. Then the query would be

with Rob and Prime coming from your user interface. I would suggest using PreparedStatement though as it will prevent users entering bad values and thereby corrupting your datamodel. If you want more info on that, search for SQL injection on Google etc.

The return value of that query will have to be checked against the maximum number allowed.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has been cross-posted in the same cryptic fashion at the Sun Java tutorials.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!