2 Replies - 2793 Views - Last Post: 04 October 2012 - 12:51 PM Rate Topic: -----

#1 bandara121  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-October 12

search button coding

Posted 04 October 2012 - 10:20 AM

Hi guys

Just wondering if anyone could point me in the right direction with this.

I have a database connection setup and can get a successful connection.

I have a JTextField called searchField . I would like to be able to search a database and be able to output the results. how would I go about searching the database for what was typed in searchField ?
Is This A Good Question/Topic? 0
  • +

Replies To: search button coding

#2 Kinaces  Icon User is offline

  • D.I.C Head

Reputation: 78
  • View blog
  • Posts: 230
  • Joined: 04-October 12

Re: search button coding

Posted 04 October 2012 - 10:27 AM

You would need separate search options. Like if I wanted to search by Author on a library. Or search by first name or last name in a phone book. That way you are searching only specific tables.
For the most basic search function just print out all results that contain whatever is in the text field.
For searching numbers could always convert them to Strings and use the same method.
Was This Post Helpful? 1
  • +
  • -

#3 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10803
  • View blog
  • Posts: 40,257
  • Joined: 27-December 08

Re: search button coding

Posted 04 October 2012 - 12:51 PM

Use the getText() method on the JTextField and bind the String to a PreparedStatement.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1