File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Reading from the database -- help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Reading from the database -- help" Watch "Reading from the database -- help" New topic

Reading from the database -- help

Derick Potgieter

Joined: Feb 19, 2004
Posts: 13
I want to know something about reading from the database.
I decided to do direct editing, reading from the database with RandomAccessFile.

Now there is two pieces of code i can use. I`m not sure which one would be better. code number one uses 2 for loops, creates a string array with all the values. Code number two makes an temp DatabaseSchema object. then reads the data byte by byte and set the values of the temp object.(this is all the columns in my database)

option 1 is a better loop and looks nice, only 10 line, but i still have
to convert the String[] to my DatabaseSchema
option 2 i can actually set the values on the DatabaseSchema directly but it is very long about 30-40 lines and looks dodgy(code is the same for all fields but only the object.set??? changes each time)

do you think that the examiner will mind about option 1 or should i
rather take the long way and be safe??

Jon Entwistle
Ranch Hand

Joined: Feb 20, 2003
Posts: 118
I don't think it is a case of what the examiner would mind - more a case of documenting important design decisions and being able to justify your choice. There is no single 'correct' answer. I would go whichever you are most comfortable defending, bearing in mind the overall goal of clarity and maintainability.



I agree. Here's the link:
subject: Reading from the database -- help
It's not a secret anymore!