• 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

Using JavaBean to keep record info

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For Data.java which implement DBMain.java,

Can I use a javabean to store data info instead using string[]?

Example:
// Method Signature require by Sun instruction
public String[] read(int recNo) throws RecordNotFoundException {
return read(recNo).toStringArray();
}

// Method singaure use through out the program
public Subcontractor read(int recNo) throws RecordNotFoundException {
return database.getSubcontractor(recNo);
}

Same to other methods like delete, update... where method implement DBMain.java will call a similar method but using object instead string[].

Understand from other post in this forum, we are allow to add in extra methods for Data.java right? Bcoz I prefer using JavaBean to store record info and manupulate it instead using string[]...

Any concern if I do like that?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As long as you do not violate the requirements. Read specs again and verify your plans. I'm convinced that Sun is using automated tool that uses Data.java as a starting point. You can use more creative solution in addition with Data.java, but your solution must follow the assignment.

Original task is carefully planned to make any sensible developer mad - they have succeeded well. String array is just one example. Same goes for locking.

I've chosen to use a general class for implementing db record behaviour in my 'backend' code. On top of this I have created URLYBIRD db record which has its own distinct set of features. For me Data.java is acting as a bridge between the specs and my own internal representation. For me GUI and rmi are both using Sun-format but as soon as backend-code is entered into, format is changed.
 
Song Jing Lim
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U means at RMI and GUI, you use string[] to represent record and only at back end conver it to javabean object and for processing?

I through for difference approach... at RMI and GUI, I use javabean object and only at back end conver back to string[] for add, edit and delete.

Any guide for that?
 
Jan Heideken
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like a perfectly valid solution.
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could be a valid solution, but not the only valid solution.
I have made my database server rather generic, so it knows nothing about the actual data it is serving (except field types and lengths, and the number of fields per record, which are stored in metadata for the specific implementation).
It takes and yields String arrays, which are converted into data objects clientside.
 
Jan Heideken
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, my solution seems to follow same tracks. I have a db which currently uses 'filestorage' for persisting the data. DB knows nothing about underlying schema. I also have a kind of metadata object for disconnecting physical and logical data layout. After implementing this I got a bit lazy. I think I've proved my point to get the developer title.
reply
    Bookmark Topic Watch Topic
  • New Topic