• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX:B&S Find Method

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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.
 
Murali Kurukunda
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jared is right.


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.
 
Jared Chapman
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Murali Kurukunda
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic