Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

meaning of data access class

shan chen
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I hope someone could help me to clearify the meaning of "data access class". The instruction.html says:
Your data access class must be called "".

Does this mean Data is the only class that DIRECTLY handle database read/write? Data can not call another class to access database?
For example, I want to defind the create method as synchronized, so that it is the method DIRECTLY handle database:
synchronized int createRecord(String []) {}
Its signature is differenct from the create method in Data:
public int create (String [] ) {}

The second method actually calls the first method.
My question: is the following understanding correct?

I CANNOT define another class which contains these synchronized methods, otherwise Data is NOT data access class. I must put the first method within either, as a member method.
Thanks to any suggestion.
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12056
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shan,
Personally I would read data access class as meaning "the class throught which I access the data".
That is, if I want to do a read, I call If I want to do a write, I call Data.write etcetera. I do not (and cannot) call multiple classes to do the same thing.
But I cannot see why the Data class itself cannot call helper classes to do more specific functions. You would need to be careful with those other classes though: if you give them public access, then someone could break your database in scary ways. You would probably only want package level access for them.
Any other opinions?
Regards, Andrew
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!