• 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
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

I am afraid my db file gets problem

 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am doing experiment on reading the db-2x2.db. I found out that the actual record starts at location 72 with length 182 as specified by the instruction: name + location+ specialty... = (32+64+64+6+8+8)
Here is what I see:

record 1 (from location 72-254)
output:
name : Dogs with Tools (by reading the first 32 bytes in the record)
location: Smallvile (by reading the next 64 bytes in the record and so on...)
specialty: Roofing
size: 7
rate: $35
owner:

record 2 (from location 254-436)
output:
name: Hamner&Tong
location: Smallvile
specialty : Drywall, Roofing
size: 10
rate: $85
owner:

record 3 (from location 436-618)
output:
name: Phil Remodeling
location: Whovile
Specialty: Roofing
size : 3
rate: $75
onwer: 00

record 4(from location 618-800)
output:
name : Fred & Nobbs (read 32 bytes)
location: Whoville (read next 64 bytes)
specialty: plumbing, heating (read next 64 bytes)
size: (read next 6 bytes, but don't get any character)
rate: 7 $1 (read next 8 bytes, the size 7 end up within this 8 bytes)
owner: 00.00


I am afraid that the db file has issue with putting the correct field in the correct bytes' sector. I did not change the original db file.


 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured out the issue in the db file.
I output one of the record:
name: Bitter Homes & Garde
location: ns Metropolis
size:
rate: 6 $65.00

In the file, there are too many space that cause the issue. For example, here is :

This is why it prints the first 32 bytes of characters from Bitter Homes & Garde
and then it prints ns Metropolis for the next 64 bytes.

I am not supposed to change db file provided and I am using Monkhouse's approach to read the records base on the total record length. What should I do?
 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I know why.
The first record actually starts from 70 to 254, length = 184 because each record has a 2 byte valid flag.
So, reading should be:
from 70 to 254
from 254 to 438
from 438 to 622
from 622 to 806
from 806 to 990
and etc.
 
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

Helen Ma wrote:I think I know why.
The first record actually starts from 70 to 254, length = 184 because each record has a 2 byte valid flag.


Exactly, that's the problem
 
We don't have time to be charming! Quick, read this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic