• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the read() method

 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "recNo" is the record's primary key. You can use the position of the record in the database file
 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9197
78
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9197
78
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic