wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S Database Access Design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S Database Access Design" Watch "B&S Database Access Design" New topic
Author

B&S Database Access Design

Chih-Wei Lee
Ranch Hand

Joined: Feb 20, 2008
Posts: 129
Hi:
I am working on B&S assignment and just started it few days ago.
My solution about Data Access is

BSDataBase.java -
1. a Singleton Class represent database file
2. has a couple of protected methods to read and write db file, like read, create, delete.

Data.java -
1. The required class as instruction said.
2. use the method provided by BSDataBase.java
3. control locking mechinism

The reason I don't want to let Data.java access db file directly is I prefer there is a class like BSDataBase.java to represent db file and provide every utility method about data access.

The role of Data.java is just to organize these methods and control locking issue. So Data.java can follow DB.java and won't be mess up.

Is this a good idea?

Could someone give me suggestion?

I appreciate it.

Lee


SCEA, SCJD, SCDJWS, SCWCD, SCJP
John Mattman
Ranch Hand

Joined: Feb 18, 2008
Posts: 45
Hi Che,
I have the same project and have the same sort of questions.I am also waiting for somebody to reply to your email. I bought the Scjd book written by Andrew Monkhouse. I am also wondering how to see what data is in the db file?.
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Hi,


Originally posted by Chih-Wei Lee:
The reason I don't want to let Data.java access db file directly is I prefer there is a class like BSDataBase.java to represent db file and provide every utility method about data access.

The role of Data.java is just to organize these methods and control locking issue. So Data.java can follow DB.java and won't be mess up.

Is this a good idea?


I did not do that personally, but I think it's a good idea. I had myself 2 helper class used exclusively by Data.
The only constraint is to have Data implementing the Interface.The rest, should be based purely on good design and meeting requirements (simple, no performance consideration needed, easy to understand...).

Originally posted by Mattman:
I am also wondering how to see what data is in the db file?.


the db file is text file, you can open it with Notepad. Its exact structure is detailed in your instructions.html.

The file start with an header (couple hundred characters) providing details on the records structure (same details as in your instructions). Just refer to your instructions for the exact length and position of each field.

Regards,
Alex
[ February 24, 2008: Message edited by: Alex Belisle Turcot ]
Frederic Thierry
Greenhorn

Joined: Apr 16, 2006
Posts: 22
Concerning your 2nd question (being able to view binary file), you can use a free binary hex editor such as "Free Hex Editor Neo" to view the file. It will display the hexadecimal bytes and its corresponding characters.
Chih-Wei Lee
Ranch Hand

Joined: Feb 20, 2008
Posts: 129
Thanks for every response.
However, I saw the instruction said: The data access file "must" be called Data.java.
Does this mean I can only use Data.java to read and write DB file?

Thanks
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Originally posted by Chih-Wei Lee:
Thanks for every response.
However, I saw the instruction said: The data access file "must" be called Data.java.
Does this mean I can only use Data.java to read and write DB file?

Thanks



No, in my opinion, it rather means that the class which will implements the interface must be called Data.

Alex
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: B&S Database Access Design
 
Similar Threads
NX:database design
Application Design
Finished my project here are my choices and I would like some feedback before I hand it in.
add, delete and modify
NX: Two questions