aspose file tools*
The moose likes Java in General and the fly likes check to see if the value if the user entered is true Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "check to see if the value if the user entered is true" Watch "check to see if the value if the user entered is true" New topic
Author

check to see if the value if the user entered is true

ryan sutton
Greenhorn

Joined: Oct 26, 2013
Posts: 4
I'm writing a program for a company to prove to them to give me a job. its a basic java console app with two layers (a presentation layer and a logic layer) it uses the crud functions with a my sql database.
its a video game storage program
on my delete game method i need it to tell the user, when they enter the wrong id number, that it is the wrong number and they need to try again.
here is the code for the presentation layer



here is my logic layer



they way its set up now it deletes just fine. if i enter 2(which is goldenye 007 in my database) it would delete golden eye and tell me game deleted. but if i type in...oh lets say 66 (which is nothing in my data base) it would still tell me game deleted
thank you in advance for any help.

PS- first post on here so if i did something wrong i apologize and please tell me what i need to do for next time
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2232
    
  47
Welcome to the Ranch.

The call to executeUpdate returns the number of rows effected so that should help you determine if a delete occurred.

BTW you may want to consider using Java naming standards ie method names start with a lower case letter.
ryan sutton
Greenhorn

Joined: Oct 26, 2013
Posts: 4
i knew that one. i realize now my question wasn't worded right. so i'm gonna put it in pseudo code
something along the lines of :

if the user input does match the id in the data base
delete the game
println( game deleted )
else
println (game not found)
then loop back to beginning

im not sure how to do it exactly and everything ive tried either made no game found everytime or still allowed me to delete even if i knewe that game wasnt there.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2232
    
  47
ryan sutton wrote:i knew that one.

Ok, so why are you not using that value to determine if the id was found in the database. For example you could have your delete method return the number of records that were deleted.

ryan sutton
Greenhorn

Joined: Oct 26, 2013
Posts: 4
Not sure actually how I would go about that. I see in my final project I didn't have it check the user i.d. and I got called out on it. Luckily I passed. I can't find anything on the web when i google it cause there are literately no articles, forums, etc. about using multiple layers, crud functions, and console apps (at least they aren't all in the same article).



and to re-track to the previous statement for the camel case( in your first post) The formatting standards at this company require the methods to have the first and following to be upper case.
ryan sutton
Greenhorn

Joined: Oct 26, 2013
Posts: 4
I apologize Tony I figured it out. IT was so easy i can't believe i over looked it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: check to see if the value if the user entered is true