• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I apologize Tony I figured it out. IT was so easy i can't believe i over looked it.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic