GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Data.delete(), ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Data.delete(), ..." Watch "Data.delete(), ..." New topic
Author

Data.delete(), ...

Jochen van Waasen
Ranch Hand

Joined: Jan 19, 2002
Posts: 33
Hi!
I have a problem with the following:
Calling delete(record) seems to delete a record but does not update the record count. The db.db provided with my assingment contains 24 records. When I delete a record the record counter keeps the same (24) but only 23 records are available.
Iterating over the 24 records throws a NullPointerException reading record(1) which I have deleted. In this case record number 1 does not exist any longer. What happens if I delete the first 12 records and append 12 records. Record number 1-12 does not exist but 13-36. The record count is 24 but I can't loop 1 to 24.
Do we have to deal with this? This problem occurs to my client refreshing the table after deleting a record.
Kind regards
Jochen
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
Look into the usage of LIVE_RECORD and DELETED_RECORD in your Data class.
Eugene.
Jochen van Waasen
Ranch Hand

Joined: Jan 19, 2002
Posts: 33
Originally posted by Eugene Kononov:
Look into the usage of LIVE_RECORD and DELETED_RECORD in your Data class.
Eugene.


Can you give me a little bit more help?
Do you suggest to write my own readRecord() method within criteriaFind()?
Jochen
Charles Dupin
Ranch Hand

Joined: Oct 18, 2002
Posts: 94
Check byte one of any record.
C.


Charles.<br />(SCJD2)
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
Jochen -
I can't be 100% sure without looking at the code, but I think if you delete a record it is marked as inactive by setting the first byte to 1. readRecord returns null if you read that inactive (deleted) record. I don't think readRecord is throwing a NullPointerException, I think it may be your code that is. If a method can return null, then you need to handle that when calling that method.
I never called delete in my application. Do your requirements specify that the user needs to delete records?
-BJ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data.delete(), ...