• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

(B&S) DBAccess Interface question

 
Sham Delaney
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am implementing the readRecord(), deleteRecord(), and updateRecord()from DBAccess.java interace. The Supplied recNo paramter to these methods is supposed to be a long.

However, I have read all my records into an ArrayList, and there is a delete and read methods on the ArrayList class that take int. Can I cast the long to an int and risk losing data if the long is greater than an int value?

What would be a good way around this?
 
Eiji Seki
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may keep doing that and document in the javadoc that your implementing class supports a reduced number of records than the interface requires.

Also, include your decision on the choices.txt document, making sure you make it clear why your solution is adequate.
 
Bob Nedwor
hangman
Ranch Hand
Posts: 215
Eclipse IDE Oracle Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sham:
I thought about doing it that way at first, then I changed my mind. They made the recNo long for a reason. So when ever I traverse through my arrayList, I just keep going until I find the element whose long recNo matches the long recNo passed into the method! I don't assume any special relationship between the index of the arrayList and the recNo of the subcontractor element.

I hope this helps.
--Bob
 
Eiji Seki
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume Sham's implementation caches all records in an ArrayList, each one in it's position, even deleted ones. So if you want record 15, you just do list.get(15). I'm not saying it is good or bad, though.
 
Sham Delaney
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob,

Do you assign long recNo to each record as you read it in from the DB file?
Is that where you create it?
 
Bob Nedwor
hangman
Ranch Hand
Posts: 215
Eclipse IDE Oracle Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is correct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic