public void purchaseTickets() {
try {
String ftime[] = new String[3];
String fdate[] = new String[3];
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");
int dCount, tCount;
String filmName = (String)fNameComboBox.getSelectedItem();
if (filmName.equals(table.getString( "FILMNAME" ) ) ) {
ftime[0] = table.getString( "FILMTIME" );
ftime[1] = table.getString( "FILMTIME2" );
ftime[2] = table.getString( "FILMTIME3" );
fdate[0]= table.getString( "FILMDATE" );
fdate[1]= table.getString( "FILMDATE2" );
fdate[2]= table.getString( "FILMDATE3" );
for( dCount = 0; dCount < ftime.length; dCount++ )
fDatesComboBox.addItem( ftime[dCount] );
for( tCount = 0; tCount < fdate.length; tCount++ )
fTimesComboBox.addItem( fdate[tCount] );
}
table.next();
}
} catch (DataSetException dse) {
dse.printStackTrace();
} finally {
try {
store.close();
table.close();
} catch (DataSetException dse) {
dse.printStackTrace();
}
}
}
This is the code for my project. Right, I have loaded in the movie titles and I want it so when the user picks a name from the combo box, the times and dates will change.
So what the program should do is check to see if the selected item in the combo box exists in the database. If so, then change the dates/times to that row in the table. Whenever I run this particular piece of the program it says "FilmDatabase.jds is not open". Can anyone tell me what I've done wrong please.