aspose file tools*
The moose likes JDBC and the fly likes How to get input from user and search from database and display results in a table format? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to get input from user and search from database and display results in a table format?" Watch "How to get input from user and search from database and display results in a table format?" New topic
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: 19761
    
  20

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 - OCEEJBD 6
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: 19761
    
  20

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get input from user and search from database and display results in a table format?