This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The long FindByCriteria[String criteria) returns the record numbers that match the criteria. I am in the process of implementing the server. When the client calls the search I want the server code to return of the records to the client. Is there a recommendation on how to do it? i.e Should there be a Record class that implements Serializable and should be used for the communication between client and server? Thanks, Murali
I have a different assignment than you, but that's basically what I did. The data class treats a record as a String, which does not include the record number. So I made a serializable Record class that wraps a record and its record number. The search method in my DataAdapter class returns a Collection of matching Records.
B.S. University of Wisconsin<br />SCJP 1.4 (85%)<br />SCJD 1.4 (92%) B&S Contractors
Joined: Oct 20, 2003
Thanks for the reply! Why do you need the record number inside the Record class? I am not sure whether I need to have the record number inside the Record class, I will decide once I implement the class. But is there a specific reason that I am missing?
Why do you need the record number inside the Record class?
The read(int i):String method returns an array of String. But after the read if we dont keep the int i value which is the record number there is no way we can figure which record this array belong to. This will be a problem if we want to update the record after reading.
You need to keep that association between record Number and data (Array of Strings) somewhere. A record object is ideal place to have it.
Thanks for the idea Jared.
Joined: Feb 23, 2004
More specifically, consider what happens when you populate your JTable with the results of a search. The row number in a JTable is not an accurate indication of a record's record number.
For example, if you populate the JTable in your GUI with all the records in the database on startup, then the 4th record in the JTable should be the 4th record in the database. But what happens if you perform a search that only returns the 4th record in the database? In this case, the 4th record in the database is the 1st row in the JTable. If you then tried updating this record, you wouldn't actually be updating the 4th record in the database, but rather the 1st one.
That's why it is important to keep a record and it's record number together. The first column of my JTable is the record number, and since the actual record number isn't important to the user, I make this column invisible.
Hope this helped.
Joined: Oct 20, 2003
This really helps..I am working on my network server design..Was just concentrating on the Search method..didn't this of bookRecord(). It makes perfect sense.