Deleting a Record from the Record Storebyte[ ] data = new byte[100]; int id = ....; // get the ID from somewhere try { int numBytes = rs.getRecord( id, data, 0 ); } catch( ArrayIndexOutOfBoundsException e ) { // record too big for the array } catch( InvalidRecordIDException e ) { // record doesn't exist } catch( RecordStoreNotOpenException e ) { // store has been closed } catch( RecordStoreException e ){ // general error }
Now, to delete a record, find the record ID of the record you want to delete:Vector recordIDs = new Vector( ); int lastID = 1; //Add a record....parameters are missing here db.addRecord( ); // Now add the ID to the vector recordIDs.addElement( new Integer(++lastID) );
Enumeration IDs = recordIDs.elements( ); while( IDs.hasMoreElements( ) ) { int id = ((Integer) IDs.nextElement( )).intValue( ); // Compare to see if this is the record you want by // invoking compare( ) which is shown next. // Then call db.deleteRecord( id ); }