File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S DB Interface read( int recNo)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S DB Interface read( int recNo)?" Watch "B&S DB Interface read( int recNo)?" New topic
Author

B&S DB Interface read( int recNo)?

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
The db interface that must be implemented has a read( int recNo ) method. If using the DataInputStream, how can one implement this read method if only one method expects an int the skipBytes. I can't see the benefit of using this method nor does it seems to assist in reading the file? So, what is the intention of the "int"?

Since I'm completely confused, I hope I've stated my question clearly enough so that I'm not confusing anyone else.

Thanks in advance for your help!
Manik Saha
Greenhorn

Joined: May 17, 2004
Posts: 11
Why dont u use RandomAccessFile instead ? For the skipBytes part, you may want to save it the first time you parse the file and then subsequently use it to access the records.

recordposition = (recordNo*sizeOfARecord) + skipBytes;

assuming recordNo 0 is the first record..
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Hi Manik,
In the B&S document, it states the following:

Data file format section
All numeric values are stored in the header information use the formats of the DataInputStream and DataOutputStream.

You stated:
For the skipBytes part, you may want to save it
the first time you parse the file and then
subsequently use it to access the records.

I'm not sure what you mean by "save it"?
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306

Since I'm completely confused, I hope I've stated my question clearly enough so that I'm not confusing anyone else.


Not me. I went through this once.


...skipBytes. I can't see the benefit of using this method nor does it seems to assist in reading the file?

Skip bytes cannot replace the seek function with RandonmAccessFile. See that skipbytes only makes an attempt to skip. Here is the javadoc for it

Makes an attempt to skip over n bytes of data from the input stream, discarding the skipped bytes. However, it may skip over some smaller number of bytes, possibly zero. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. This method never throws an EOFException. The actual number of bytes skipped is returned.



So, what is the intention of the "int"?

Don't caught you question clearly. The int recNo is to specify the record you like to pull from database. 1 (or 0)means first record 2 (or 1) means second record.

I think you might have already figured out. If not take a look at the following url's.


http://www.coderanch.com/t/186390/java-developer-SCJD/certification/RandomAccessFile

http://www.coderanch.com/t/186352/java-developer-SCJD/certification/urlyBird-requirement-clarification

http://www.coderanch.com/t/186351/java-developer-SCJD/certification/db-access-returning-String


[ November 01, 2004: Message edited by: jiju ka ]
[ November 01, 2004: Message edited by: jiju ka ]
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Hi JiJu,
Ahhhh, now I follow. Thanks for your help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: B&S DB Interface read( int recNo)?
 
Similar Threads
DBMain method need throw RemoteException?
NX: Error overriding interface method.
Altering DB interface
GuiController design
RMI and Adapter Pattern for URLyBird