Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Query using WHERE clause.

 
Rose Jac
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to implement this method, but the where clause in the sql seems to be not working. My database has the fields : ID, lastName, firstName, mi, address, city, state, telephone, email with 2 records.
The code attempts to display a specific record whose id is entered by the user in a JApplet's Textfield and then, the other fields of the reocrd corresponding to that id is displayed on the other textfields on clicking the 'View' JButton.
Do help.



Thanks!
 
Sudheer Bhat
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it throwing an exception? Even if it throws an exception you will never know that unless you run debugger and step line by line through the code because you have a empty catch block.

Also probably you want to use a PreparedStatement instead of Statement.
 
Tim Moores
Bartender
Posts: 2954
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is "ID" really a varchar field? You're surrounding it with single quotes as if it were...

Yet another reason to get in the habit of using PreparedStatement.
 
Rose Jac
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much! That worked.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic