• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get input from user and search from database and display results in a table format?

 
Ashwin Kumar Balasubramanian
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ashwin Kumar Balasubramanian
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob Thank you so much.. Got it.. ya you were correct. THANK YOUUUUUU..
 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic