• 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

db-file question

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello fellows!

I am a long time reader but a first time poster to this great forum:)

I downloaded my assignment, URLyBird and I have some conserns about the db-file.

I have opened this with the encoding of US-ASCII as the instructions stated is was and it looks like this at the beginning of the file. Does this look correct?

Best regards
Peter
db.gif
[Thumbnail for db.gif]
 
Ranch Hand
Posts: 221
Scala Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,


Welcome to the SCJD Forum in JavaRanch!


Each assignment is unique to each individual going for the SCJD certificaction.

Please see The Database File Reader Tool in the SCJD FAQ


HTH,


Carlos.
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Carlos!

I have tried that and I am a little confused when the result is:
Number of fields in each record: 1311 (if I remember correctly, I dont have the IDE up and running at the moment)

This is my intruction:
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
2 byte numeric, number of fields in each record

Schema description section.
Repeated for each field in a record:
1 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
1 byte numeric, field length in bytes
end of repeating block

Data section.
Repeat to end of file:
1 byte flag. 00 implies valid record, 0xFF implies deleted record
Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information

End of file

BR
Peter
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,

Welcome to the JavaRanch!

The file is not a plain text file, hence the squares and funny characters you'll see when opening it with NotePad for example. You could use a HexEditor or just use Roberto's file reader. You can also write your own little database file reader, based on the instructions you got (using a RandomAccessFile or a DataInputStream).
This was my own file reader (of course you'll have to make changes according to your instructions:

Number of fields in each record: 1311

I think that is wrong, because the normal number of fields would be less than 10. Maybe it could be the value of your magic cookie.

Good luck!
Kind regards,
Roel

[edit] changed code snippet according to structure database file
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much for taking the time to help me Roel!

I feel I have to look more in to this. I have tried your app and I cant get it to work properly. I am missing something. I will try more tomorrow. Must sleep now.

Goodnight.

/Peter
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,

Thanks very much for taking the time to help me Roel!

Not a problem at all! One year ago I was in the same position as you: starting with SCJD and I was glad people took the time to help me with my questions, so just giving something back to the community.

At a first glance to the description of your database file your file only has magic cookie and number of fields. My database file has magic cookie, length of a record and number of fields. So try to uncomment lines 12 and 13, and have another shot.

Sweet dreams about SCJD-assignment ;)

Kind regards,
Roel
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy, Peter!

Champion, were you able to display the records of your database file already?
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys!

Thanks very much for your help guys. Its amazing

SadlyI cant get it to work. I am wondering if this is where I fail

n bytes (defined by previous entry), field name

What does that mean?

BR
Peter
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, Peter!

It is the number of bytes that you read just previously.
You couldn't read it, even with the DBFileReader tool?
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roberto Perillo wrote:You couldn't read it, even with the DBFileReader tool?

If the structure of his database file (supplied in one of his previous posts) is consistent with the one from his instructions, it is completely normal he can't read it with your tool, because it seems his database file doesn't have a recordLength (between magicCookie and numberOfFields)

@Peter: i changed my snippet of code to read the database file according to the description you provided in 1 of your earlier posts. Can you give it a try and see of you get any meaningful output?

Kind regards,
Roel
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roel De Nijs wrote:If the structure of his database file (supplied in one of his previous posts) is consistent with the one from his instructions, it is completely normal he can't read it with your tool



Obviously. The only thing different in the format of his schema is that the record length is not informed, so he should be able to read it with DBFileReader with small modifications in the code.
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roel that made the trick!

Now I know that there are nothing wrong with the file. (I didnt think it was but....) Now I am gonna studdy this to fully understand it.


Thanks again for all your help!

BR
Peter
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roberto Perillo wrote:he should be able to read it with DBFileReader with small modifications in the code.

Your DBFileReader is indeed a great tool and these small modifications should make it possible to read his database file:And put every line about recordLength (96, 100, 104, 110, 111) in comment (or just delete them). Now he has 2 programs to read his database file

@Peter
another important note: remember to be sure to have an original copy of your database file, because you have to provide the original copy when submitting (and it is also very useful when you corrupted your file while modifying it)

Kind regards,
Roel
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have copies all over
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic