SCEA, SCJD, SCDJWS, SCWCD, SCJP
SCJP 1.4,<br />SCJD Java 2,<br />...
Originally posted by Jason Moors:
Hi Aaron,
A possible solution if you don't want to handle the RecordNotFoundException in your find method is to create a new private method for actually reading the record which doesn't throw an exception, this method would return null array if the record is not found or marked as deleted.
This new method would then be called by both the read and find, the read method would check if the returned value is null and throw a RecordNotFoundException, and the find method could ignore null array and not add to search results.
Hope it helps,
Jason
[ June 23, 2008: Message edited by: Jason Moors ]
Originally posted by Jo�o Batista:
Think about the kinds of Exception that a method can throw and how they affect the method signature.
You'll find a way to disguise that IOException.
Originally posted by Aaron John:
Okay, for example in the read method, the read method will need to read the actual database file, but these kind of operations may throw an IOException. How would you handle the IOException so that it doesn't propogate to calling methods?
SCJP, SCJD
Originally posted by Jethro Borsje:
You can also choose to read the data file into memory before hand, the Data class would then just hold a Map of the records in memory. Using this approach you do not have any IOExceptions during the usage of the Data class. You can catch these errors before hand we reading the file into memory. In my opinion this is also better, because you may not want th DB server to run at all if some serious IOExceptions occurred.
Originally posted by Aaron John:
Ah okay, that is a good approach. Thanks for that. How often would one read the database in order to have the latest records in memory?
SCJP, SCJD
Originally posted by Aaron John:
Hi Joao,
I could not follow your previous post. Could you give me an example please?
Thanks.
Don't get me started about those stupid light bulbs. |