Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Apr 27th, 2005, 1:47 PM   #1
Vengeance
Newbie
 
Join Date: Apr 2005
Posts: 8
Rep Power: 0 Vengeance is on a distinguished road
Java - Searching a table in a database - small problem.

Ok, below is the code.

void searchBtn_actionPerformed(ActionEvent e) {

String searchfilmName = searchtxtbox.getText();

try {
store.setFileName( "FilmDatabase.jds" );
store.setUserName( "odeon" );
store.setPassword( "1234" );
table.setStoreName( "FILMTABLE" );
table.setStore( store );
table.open();

table.setSort( new SortDescriptor( new String[] {"FILMID"} ) );
table.first();
while ( table.inBounds() ) {

table.getInt( "FILMID" );
String filmName;
filmName = table.getString( "FILMNAME" ).toLowerCase();

if (filmName == searchfilmName) {
System.out.println( "Film found! Synopsis: " + table.getString( "SYNOPSIS" ) );
}

else {
System.out.println( "Film not found!" );
}

table.next();


/* System.out.println( table.getInt( "FILMID" ) + ": "
+ table.getString( "FILMNAME" ) + ", "
+ table.getString( "SYNOPSIS"));
table.next();*/
}
} catch ( DataSetException dse ) {
dse.printStackTrace();
} finally {
try {
store.close();
table.close();
} catch ( DataSetException dse ) {
dse.printStackTrace();
}
}

}
}

Now, as you can see there is a section of code in a comment. When I use this code, it prints off all the information of the database perfectly.
Prints the ID, name, and synopsis. But, for some reason when it's searching it doesn't recognise things.

For instance, earlier I made a small adjustment so it would print off the string entered and the string it was comparing it to.

Now, I type in "hitch" which is one of the films in the database it said "hitch, hitch" both look exactly the same right? No capitals..spaces, etc.

But, for some reason it doesn't see them as the same.

Can anyone help me with this? I'm so confused as to why it doesn't think they're the same thing.

Btw, I'm using Jbuilder and importing classes JDataStore and DataExpress.

I can extract data from the database fine...it's just it thinks the strings aren't the same even though they are.

Last edited by Vengeance; Apr 27th, 2005 at 2:15 PM.
Vengeance is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:25 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC