wood burning stoves 2.0*
The moose likes JDBC and the fly likes SQL Query using WHERE clause. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Query using WHERE clause." Watch "SQL Query using WHERE clause." New topic
Author

SQL Query using WHERE clause.

Rose Jac
Ranch Hand

Joined: May 20, 2011
Posts: 33
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

Joined: Feb 22, 2011
Posts: 75
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: May 20, 2011
Posts: 33
Thank you very much! That worked.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL Query using WHERE clause.
 
Similar Threads
Connecting to a database through servl
Java dunce is back...still can't figure this out
problem with MS Access and max
Resultset processes 1 record
Returning a 0 value error