This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

field for record number in database file?

 
prakash bayas
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
i am writing subcontractor assignment. in this, i wrote the interface db and class data implementing this interface only.
In the book, Denny's dvd application, gui controllers method for finding with search criteria returns list of dvds. this is because this method returns list of dvd objects. but as per the interface provided, in this method for subcontractor, i am returning first int[] of record numbers matching search criteria and for every number read(recNo)ing record.
when i am matching say Dogs With Tools, able to filter records with this string but how should i identify these obtained records with unique record number as this field is not present in database.
when application starts record numbers will be displayed in sequence 1, 2 but this sequece get changed for new filtered results and a call to read with these new record numbers return different records.
also, how should i increment this recNo field, as of now i am hardcoding this in retrieveSubcontractor(long locationInFile) method of SubcontractorFileAccess class.
the book from andrew and terry, for this certification, has helped a lot along the way!, have never done multithreading before this book!
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Prakash. Welcome to JavaRanch!

Champ, sorry but I didn't quite get your question... what exactly is your doubt? Could you please elaborate it a little better?
 
Roel De Nijs
Sheriff
Posts: 9158
76
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 think he has a little bit doubts about what he should use as a record number to identify each reacord in the database file. I would say just use a logical record number. That means the 1st record in the database has 0 as record number, the 2nd one has 1 and so on.

In your find-method you will return an array with the matching records. So if the 1st, 3rd and 4th record match the specified criteria the method will return an array containing 0, 2 and 3. So you use the record numbers corresponding to the position of the record in the database file (and NOT the record number corresponding to the position in the filter results)
 
Matthew McDonald
Greenhorn
Posts: 6
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am doing the same project for my diploma, and the database file itself doesn't have a recNo field.. fields are; name, location, specialties, size, rate and owner.
i am having the same problem... i am thinking of having a "database" class that creates an instance of the database by reading the data from an inputStream... and adding the recNo field to the object at the same time... so the recNo field only exists in the application, not the database file itself... does that make any sense?...
 
Roel De Nijs
Sheriff
Posts: 9158
76
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Matthew,

First of all a warm welcome to the JavaRanch!

No worries, I'm quiet familiar with the database structure, so I know the record structure has no record number You could create a value object which holds the record number and the actual data of a contractor. That makes sense, but you always have to convert between this object and a String[] (because all your methods use a String[] in its signature). And I don't know if you will use String[] at the client or use a value object instead, but that would result in yet again a conversion between String[] and object.

Kind regards,
Roel
 
prakash bayas
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you,
roel, now assigning record number to a subcontractor record while looping!
roberto, i am doing fine!, just stumbling sometimes between interface provided in assignment and interface present in book,
matthew, can be done this way!,
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic