• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

URLyBird - Maybe my database file come messed !! Helpp me

 
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think my database file came messed or I'm really lost about database schema...
Someone could help me ???
 
Sheriff
Posts: 11606
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
Fernando,

Don't think anybody can help you if you provide so little information. But maybe this thread can point you in the good direction

Good luck,
Regards,
Roel
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roel

Actually I have so many doubts...that I'm completely....lost....
I'll formated some question here.....
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi for all

This is my assignament:


The format of data in the database file is as follows:
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

Database schema
The database that URLyBird uses contains the following fields: Field descriptive name Database field name Field length Detailed description
Hotel Name name 64 The name of the hotel this vacancy record relates to
City location 64 The location of this hotel
Maximum occupancy of this room size 4 The maximum number of people permitted in this room, not including infants
Is the room smoking or non-smoking smoking 1 Flag indicating if smoking is permitted. Valid values are "Y" indicating a smoking room, and "N" indicating a non-smoking room
Price per night rate 8 Charge per night for the room. This field includes the currency symbol
Date available date 10 The single night to which this record relates, format is yyyy/mm/dd.
Customer holding this record owner 8 The id value (an 8 digit number) of the customer who has booked this. Note that for this application, you should assume that customers and CSRs know their customer ids. The system you are writing does not interact with these numbers, rather it simply records them. If this field is all blanks, the record is available for sale.



I actually dont understand and my database file has some strange characteres....
I need help.....

I attachment some printscreen of my databasefile and bold in red...this strange characteres...
1)what's it ???
2) I dont know what mean MAGIC COOK in the begin of file....???
data.jpg
[Thumbnail for data.jpg]
DataBaseFileScrenn
 
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 Fernando,

The database file looks reasonable to me. The problem is that you are trying to view it in a text editor, when it is a binary database file.

The JavaRanch SCJD FAQ has some generic information on what the magic cookie is used for.

Take a look at the following hex dump of a similar (but not the same) file:

Offset in bytesHex values Ascii equivalent
0000000 0000 0101 0000 9f00 0700 0400 616e 656d  nul nul soh soh nul nul nul 9f nul bel nul eot n a m e
0000020 4000 0800 6f6c 6163 6974 6e6f 4000 0400   nul @ nul bs l o c a t i o n nul @ nul eot
0000040 6973 657a 0400 0700 6d73 6b6f 6e69 0067   s i z e nul eot nul bel s m o k i n g nul
0000060 0001 7204 7461 0065 0008 6404 7461 0065   soh nul eot  r  r a t e nul bs nul eot d a t e nul
0000100 000a 6f05 6e77 7265 0800 5000 6c61 6361  nl nul enq o w n e  r nul bsnul P a l a c
0000120 2065 2020 2020 2020 2020 2020 2020 2020   e sp sp sp sp sp sp sp sp sp sp sp sp sp sp sp
0000140 2020 2020 2020 2020 2020 2020 2020 2020   sp sp sp sp sp sp sp sp sp sp sp sp sp sp sp sp
0000200 2020 2020 2020 2020 2020 5320 616d 6c6c   sp sp sp sp sp sp sp sp sp sp sp S m a l l
0000220 6976 6c6c 2065 2020 2020 2020 2020 2020   v i l l e sp sp sp sp sp sp sp sp sp sp sp
0000240 2020 2020 2020 2020 2020 2020 2020 2020   sp sp sp sp sp sp sp sp sp sp sp sp sp sp sp sp
0000300 2020 2020 2020 2020 2020 3220 2020 5920   sp sp sp sp sp sp sp sp sp sp sp 2 sp sp sp Y
0000320 3124 3035 302e 2030 3032 3530 302f 2f37   $ 1 5 0 . 0 0 sp 2 0 0 5 / 0 7 /
0000340 3732 2020 2020 2020 2020 4300 7361 6c74   2 7 sp sp sp sp sp sp sp sp nul C a s t l


In this case, the blue text is the magic cookie - as you can see, the 4 bytes (00 00 01 01) are reasonable if you look at them as hex characters, but are meaningless as ASCII strings (nul, nul, soh, soh) - WordPad does not even give you the equivalent strings (0x00 = null), it just prints blanks.

The green text is my schema section. Note that I have more data and different sized fields than your instructions, so do not pay too much attention to the actual data being shown.

The brown text is the very first record to be read.
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Andrew...thanks again...
Now i'm using Notepad++ to see a file....
So....What should I do with the cookie e meta-data scheme ?? Should I validate this values when final user select and run the program ? or just ignore and read the data session ??
 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fernando,

Get a hex editor like the one Andrew used in the post above. It will be invaluable to you while you are working on this project. There are a few free ones aout there. A good Google query should return a few of them.
 
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
My recommendation is in line with what is in the FAQ entry I mentioned earlier: I would recommend you use this data to validate that the data file is correct before you start working with it.

Regards, Andrew
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeahh I read and I'll validate...Thanks
 
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fernando!
Hey look this link it is a "problem solver"
SCJD

I Hope it Help!

Regards!
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip Julio....but I've already read.......twice !!!
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can upload databasefile using text to replace image.
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean
 
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
Fala Fernando!

Were you able to read your .db file already? I created a simple tool (you can find it here) that reads the .db file and prints its content on the console. Take a look at it if you still didn't get to read it. I think it might be helpful!
 
phung duc tho
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you upload db file
 
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

phung duc tho wrote:Can you upload db file



Champion, do you have one of the assignments? If so, you should have a .db file, which you can read with this tool. If not, unfortunately this file cannot be shared with other people.
Also, please take a look at an important administrative private message I just sent you.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic