• 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: Dynamic DB

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am trying to make my DB as dynamic as possible; using the header and field data within the database.
I have created a class called DBMetaData that holds all the header and field data. Within my Data class I have created ByteBuffer recordData[] that holds a single record. See code below:

Has any one else noticed that the order of the fields description within the database is not the name as the order of the records.
I wanted my read method to look something like:

However this will not work, beacuse of the order that the records fields have been written.
So my question can anyone think of a way of sorting the fields data into the same order as the records and still keeping my code dynamic?
I hope you can understand what I mean.
Thanks
Chris
[ September 23, 2003: Message edited by: Chris Harris ]
[Andrew: Put code into [code] blocks]
[ September 23, 2003: Message edited by: Andrew Monkhouse ]
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for all the code blocks. I am still getting used to this forum.
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris,
Do you mean that fields order as given in the header section of your file does not match fields order within the records ?!
Which assignment (including version number) have you ?
Regards,
Phil.
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the Bodgitt and Scarper assigment. After opening the DB in TextPad it looks like the field description are in the same order as in the records. SO there must be something wrong with the way i am storing the field names. hmm I will have to look in to it
Should I allow the client to get the field names from the DB so that they can be used in the JTable?
Thanks
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris,

SO there must be something wrong with the way i am storing the field names. hmm I will have to look in to it


Indeed.

Should I allow the client to get the field names from the DB so that they can be used in the JTable?


It sounds like a good idea.
Good luck with your assignment.
Best,
Phil.
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The assigment stats that:

Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package. Each must have a zero argument constructor and a second constructor that takes a String that serves as the exception's description.


Do you think I will lose marks if I add another constructor that takes a Throwable cause?
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris,

Do you think I will lose marks if I add another constructor that takes a Throwable cause?


No, IMO. I interpret the instructions as this : the zero argument constructor and the one that takes a String must be there as a minimum.
Best,
Phil.
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Phil,
Thanks, as my plan is to wrap the IOException that could be thrown when attemting to read the DB into the RecordNotFoundException.
Chris
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris,
I have put all your code between [code] and [/code] tags. If you edit your orignal post you will see where I put them. They help to preserve the indenting of your code which makes it easier to read. There is a button below the edit pane which will insert the [code] and [/code] tags into your post so you don't have to try and remember how to do it.
It seems like Philippe has already answered your questions
Regarding the code

I think "recordSize" is really "dataSectionSize".
I would recommend against using hard coded values for schema size and record length. I think they should either be constants or calculated from the file you are reading (my preference would be the later).
Regards, Andrew
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the advice. I am about to start on the find method and have a few question. If you think I should start a new topic for this please say. The assigment states:

What does this really mean?
1) would "Fred" match a record of "Tom, Fred"? i.e should the input be compared against all tokens in the record?
2) would the input "Tom Fred" match the record "Fred"? i.e should each tokens in the input be compare against the each token of the record?
My current idea for this problem involves using the new split method in String with the new regular expression classes. Or would I be better to uses a StringTokenizer instead of the split method?

Chris
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris,
I think you should open a new topic for this - it is not really part of the "dynamic db" discussions.

1) would "Fred" match a record of "Tom, Fred"? i.e should the input be compared against all tokens in the record?


No, the starting characters do not match.

2) would the input "Tom Fred" match the record "Fred"? i.e should each tokens in the input be compare against the each token of the record?


No, the starting characters do not match.
All you are looking for anything that starts with the search parameter. You are not looking for a "contains" or "ends with".
Note that the output from the find will give more data than you want to display in your GUI, which should be limited to exact matches. (check this in your instructions though - I could be wrong).
Regards, Andrew
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chris Harris: Do you think I will lose marks if I add another constructor that takes a Throwable cause?

Philippe Maquet: No, IMO. I interpret the instructions as this : the zero argument constructor and the one that takes a String must be there as a minimum.

How about if I made the zero argument and String constructors private?
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Has any one else noticed that the order of the fields description within the database is not the name as the order of the records



My schema definition in file matches exactly with data layout. To be more specific my file have number of fields in each record, schema description section and thenn data section.
In schema description, there are length of field name, field name and field length for each field. Nothing more. The ordering is implicit.

In your case the ordering should be explicit. If so is there a field(s) specifying order?. Please put more light. Just curious.
[ November 03, 2004: Message edited by: jiju ka ]
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic