• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

If statement problem!!

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I'm experiencing a strange problem with my if statement. Basically, I'm wanting an error message to come up when a user does not enter a name. However at the moment, the if statement always produces the same result - even if there is no data entered into the txt field. So at the moment, all the respones from the validateText() method are "Good", even when there is no text in the text field. Any help would be very appreciated. Thanks. Pete


 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use .equals() to compare your Strings instead of ==
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

String order = "INSERT INTO orders (name,type,capacity,voltage,quantity) " +"values ('"+ cust+"','"+ type +"','"+ capacity+"','"+voltage+ "','"+ quantity+"')";



Appending SQL statements together like that is a bad idea. You should use PreparedStatement. Look it up in the API documentation.


[ November 16, 2005: Message edited by: Jesper de Jong ]
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey... cust is a string ... yu cannot use == on that. That will compare references and not the data. Use cust.equals("") instead
 
Peter Matthews
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys - appreciate the help!
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic