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.