| Author |
How to get input from user and search from database and display results in a table format?
|
Ashwin Kumar Balasubramanian
Greenhorn
Joined: Aug 03, 2012
Posts: 5
|
|
Hi Friends,
I want to look up the database for an input given by the user which is searched from the database. This then displays the information in the form of a table. Am a newbie to java and swing. can you all please help me with this please.
My Database looks like this:
FIRST | SECOND | RESULT
1 | 2 | 3
5 | 7 | 8
7 | 4 | 2
If the user types the number " 1 " it must display the whole data like
FIRST | SECOND | RESULT
1 | 2 | 3
I had written a code for this. How to incorporate this into the prepared statement? Am not getting the output but an error.
Please help me with this code..:'( :'(
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Use executeQuery() instead of executeQuery(sql). With the latter you're asking the PreparedStatement to ignore the special meaning of the question mark and just execute the query as it is. With the former the PreparedStatement takes the query as you've used to create it with all the parameters you've set for it.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Ashwin Kumar Balasubramanian
Greenhorn
Joined: Aug 03, 2012
Posts: 5
|
|
Hi Rob Thank you so much.. Got it.. ya you were correct. THANK YOUUUUUU..
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You're welcome.
|
 |
 |
|
|
subject: How to get input from user and search from database and display results in a table format?
|
|
|