The Artima Developer Community
Sponsored Link

Java Answers Forum
jbuilder and mysql [easy question for data search]

1 reply on 1 page. Most recent reply: Jul 7, 2002 12:04 AM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Giovanni

Posts: 2
Nickname: satcom
Registered: Jun, 2002

jbuilder and mysql [easy question for data search] Posted: Jul 6, 2002 3:30 PM
Reply to this message Reply
Advertisement
Hi all,

I've a little problem with an application java done with jbuilder 6 and a mysql database. I prepared the application which is connected to the db and i used a querydataset in order to retrive data from the db. the query has the command "select * from db_table"

I can see all the db data displayed in my application.
[ in the application there are 3 textarea, and all of them are connected to one column of the table respectively]

I'm using a jdbnavtoolbar for navigate in the database and i can work without problems.

in order to search data in the application i used a jdbnavfield, and a jcombobox to switch the columns where to search data

if i search something in the database i can retrive the correct informatios only if i type the exact words which are contained in the beginning of the records.

for example the column "car" has several records
and one record has more than one word as "toyota Celica" the jdbnavfield has a positive results only if i type "toyota", while if i type only "celica" the result is "no match found"

my problem is that i don't want to use a jcombobox to switch the columns whether to search data, while i would like to have only one jdbnavfiled (or something else) which
allow me to type the word to search and it will search in all the columns of the table automatically in order to retrive the infomration requested.
If i type "yot" it should send me to the record of toyota celica. since i'm not very expert in java i would like to ask you some helps to do this.

I apologize for the long post, and i hope someone can help me on this.

thank you very much
regards
Giovanni


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: jbuilder and mysql [easy question for data search] Posted: Jul 7, 2002 12:04 AM
Reply to this message Reply
The easy way to filter by any text in a particular column is simply to add a WHERE clause to your SQL; instead of:
   String sql = "select * from db_table";

you do this:
   String sql = "select * from db_table where car like '%" + carField.getText() + "%'";
(I'm assuming that the name of the column in your database is "car").

Flat View: This topic has 1 reply on 1 page
Topic: pressing keys! Previous Topic   Next Topic Topic: Some more applet help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use