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 fields' information of DataBase Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Reading fields Watch "Reading fields New topic

Reading fields' information of DataBase

Musab Al-Rawi
Ranch Hand

Joined: Aug 06, 2007
Posts: 231

there is nothing in the assignment that says that we have to read fields' information of the database (such as field length, name etc).

but if we want our GUI to be separate from the DB layer i think we should read that kind of information of the DB and provide the functionality of querying that info to the Data class to allow the GUI to be as separate as possible.

not quite sure if i made my point clear but what do you think ? is there anyone who didn't read the DB fields of the database and passed with an excellent/ V.Good grade?

Peter Hat

Joined: Oct 29, 2007
Posts: 6
The way I read it, it's your choice if you want to hard code the field names or to read them dynamically, and I think both can be ok, as long as you documents what considerations you went through while you reached your decision.

The documentation of your thoughts and reasons for your decisions, is more important than your actual choices, as I understand it.
Terence Lai

Joined: Dec 09, 2007
Posts: 8
How about the order of the fields? Are they always in the same order as shown in the sample database file?

Can I hardcode the order of the fields as shown in the sample database file? This will make the implementation easier.

Alternately, my program will need to read the schema description from the database file and find out the order of the fields dynamically.

Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516

well.. the sample database IS your database, so whatever order the fields are in is the order they are..

And the magic cookie allows you to identify that the file is really your database.. So SUN will only be able to use the correct database with your application...

As for handling that dynamically or not, it's a design choice.. However, I believe you will have to write the code (throwable or not) to find the exact size of your header.. might as well read the value, keep the code and do it dynamically

I agree. Here's the link:
subject: Reading fields' information of DataBase
It's not a secret anymore!