| Author |
the read() method
|
Julio Cesar Marques
Ranch Hand
Joined: Mar 21, 2009
Posts: 66
|
|
Hi guys!
in DBMain i have to implement the method:
public String[] read(int recNo) throws RecordNotFoundException;
but it expects a int recNo. How i can get this value?
In File Description don't have a field named idRec. What do i?
|
Julio Cesar Lopes Marques
Sun Certified Java Developer 5, Sun Certified Java Programmer 5
|
 |
Roberto Perillo
Bartender
Joined: Dec 28, 2007
Posts: 2212
|
|
The "recNo" is the record's primary key. You can use the position of the record in the database file
|
Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
|
 |
Julio Cesar Marques
Ranch Hand
Joined: Mar 21, 2009
Posts: 66
|
|
hmmm ok.
One more thing i need to use headers and schema from db file to recovery data or i can jump to data section (pos 71 in my case) directly and slice parts to get data? I think that using the entire file is the right, but i think i don't need write a generic .db file reader but a db-2x1.db reader in this case i'll lost my time parsing headers and schema.
|
 |
Roberto Perillo
Bartender
Joined: Dec 28, 2007
Posts: 2212
|
|
|
You can decide that. For instance, you can decide to read the db schema "on the fly", or you can hardcode it. I myself hardcoded it. I know others created a way to read it dynamically. Just remember to justify your decision in the end!
|
 |
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4351
|
|
I'm one of those that created a way to read it dynamically and that's not that hard. main advantage of this approach: you could use the data-class for other files having a similar data-structure but of course this isn't a requirement for the assignment, so you don't have to do it.
whatever you choose, justify in choices.txt because for many things there is no right or wrong if you have a valid argumentation for doing it that particular way
|
SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
|
 |
Julio Cesar Marques
Ranch Hand
Joined: Mar 21, 2009
Posts: 66
|
|
Hi Roel!
I'm never think by this point of view, maybe have one robust class able to understand *.db is not too bad!
[]'s
|
 |
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4351
|
|
|
if you have a dynamic db-schema you can handle e.g. changes in field lengths without changing your data-class (if header info is updated appropriately of course). you could even handle a file where a column is added or removed without altering your Data-class (the business logic should be changed of course)
|
 |
 |
|
|
subject: the read() method
|
|
|