aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: Some question about DBAccess Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: Some question about DBAccess" Watch "NX: Some question about DBAccess" New topic
Author

NX: Some question about DBAccess

Wu Ming
Greenhorn

Joined: Nov 01, 2003
Posts: 13
Server
Required Interface
Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:
public interface DBAccess{
public String [] readRecord(long recNo) throws RecordNotFoundException;
public void updateRecord(long recNo, String[] data, long lockCookie) throws RecordNotFoundException, SecurityException;
public void deleteRecord(long recNo, long lockCookie) throws RecordNotFoundException, SecurityException;
public long[] findByCriteria(String[] criteria);
public long createRecord(String [] data) throws DuplicateKeyException;
public long lockRecord(long recNo) throws RecordNotFoundException;
public void unlock(long recNo, long cookie) throws SecurityException;
}
Question:
1. can I modify the DBAccess directly? For example, add some methods to this interface. Such as :
public string[] getFieldInfo() ?
2. can I modify the methods in the DBAccess ? For example, add ' synchronized ' to the method?
Thanks.


SCJP, SCJD, SCEA (?) ....
Jacques Bosch
Ranch Hand

Joined: Dec 18, 2003
Posts: 319
Hi Wuu.

1. can I modify the DBAccess directly? For example, add some methods to this interface. Such as :
public string[] getFieldInfo() ?

Not sure. But I don't think so. Would be better if you put those methods in your implementation of the interface. Or create a second interface if you have to. Rather don't change what they gave you (except for the comments)

2. can I modify the methods in the DBAccess ? For example, add ' synchronized ' to the method?

Definitely not. You are not allowed to change the method signatures.


Jacques<br />*******<br />MCP, SCJP, SCJD, SCWCD
Wu Ming
Greenhorn

Joined: Nov 01, 2003
Posts: 13
Hi Wuu.
quote:
--------------------------------------------------------------------------------
1. can I modify the DBAccess directly? For example, add some methods to this interface. Such as :
public string[] getFieldInfo() ?
--------------------------------------------------------------------------------
Not sure. But I don't think so. Would be better if you put those methods in your implementation of the interface. Or create a second interface if you have to. Rather don't change what they gave you (except for the comments)

Maybe, It is better for me to define another interface implemenation of the interface DBAccess. And then let Data to implementation DBAccess.
quote:
--------------------------------------------------------------------------------
2. can I modify the methods in the DBAccess ? For example, add ' synchronized ' to the method?
--------------------------------------------------------------------------------
Definitely not. You are not allowed to change the method signatures.
--------------------
That is to say, I can not modify any of the methods they provide. even add 'synchronized ' to the method.

Any guy with the NX give me some advice.
Jacques Bosch
Ranch Hand

Joined: Dec 18, 2003
Posts: 319
You can extend the DBAccess interface and then implement the new, extended, interface in your Data class.
An interface is not concerned with implementation. Synchronizing a method is one way of implementing it. So no, you cannot add "synchronized" to the method definition in the interface, but you can add "synchronized" to your implementation of that method in your Data class.
Hope that helps.
Wu Ming
Greenhorn

Joined: Nov 01, 2003
Posts: 13
That is to say, if I add 'synchronize ' to the method, it will meet the requirement of the assignment:
***************************************************************
Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:
*********************************************************************
public Data implements DBAccess{
public synchronized String [] readRecord(long recNo) throws RecordNotFoundException {}
public synchronized void updateRecord(long recNo, String[] data, long lockCookie) throws RecordNotFoundException, SecurityException {}
public synchronized void deleteRecord(long recNo, long lockCookie) throws RecordNotFoundException, SecurityException{}
public synchronized long[] findByCriteria(String[] criteria){}
public synchronized long createRecord(String [] data) throws DuplicateKeyException{}
public synchronized long lockRecord(long recNo) throws RecordNotFoundException{}
public synchronized void unlock(long recNo, long cookie) throws SecurityException{}
}
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Yes.
The reason is that is not considered part of a method's signature.
Hope that helps,
George


Regards, George
SCJP, SCJD, SCWCD, SCBCD
Jacques Bosch
Ranch Hand

Joined: Dec 18, 2003
Posts: 319
Yes Wu. That is fine.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5406
    
  13

Anton Kuzmin,
Your post was moved to a new topic.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: Some question about DBAccess