This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S question about new values in updateRecord Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S question about new values in updateRecord" Watch "B&S question about new values in updateRecord" New topic
Author

B&S question about new values in updateRecord

Steve Taiwan
Ranch Hand

Joined: Jul 01, 2003
Posts: 166
I assume, in updateRecord(long recNo, String[] data, long lockCookie),
String [] data contains only new values and no old values.
am I correct?

ex: If I want to update name of recNo 1, then in String[] data,
the data structure should be like data[0]="new name", data[1]="", data[2]="", data[3]=""
........am I right??



Steve Taiwan<br />SCJP 1.2, SCJD 1.4, SCWCD 1.3, SCBCD 1.3, OCP 8i DBA, SCEA
Jared Chapman
Ranch Hand

Joined: Feb 23, 2004
Posts: 81
Hi Steve,

Good question.

I do not think you should use "" as an indication that a field should not be updated. What would happen if you wanted to intentionally delete a field?

This is how I have handled it so far:

This allows me to update a record in one of two ways:
1. String[] newData = {"new name", "old location", ..., "old owner"};
OR
2. String[] newData = {"new name", null, null, null, null, null};

And as always, it will be well documented.


B.S. University of Wisconsin<br />SCJP 1.4 (85%)<br />SCJD 1.4 (92%) B&S Contractors
Steve Taiwan
Ranch Hand

Joined: Jul 01, 2003
Posts: 166
Thank you for the reply.
Greate solution.
I redesigned and changed my code according to your suggestion.
Thanks again.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: B&S question about new values in updateRecord
 
Similar Threads
Difference b/w Cookie and LockCookie
Is checking for SecurityException in updateRecord method necessary?
Can I use another db file for optimistic locking?
question about the update
B&S 2.2.2 updateRecord()