File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I am afraid my db file gets problem

 
Helen Ma
Ranch Hand
Posts: 451
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Roel De Nijs
Sheriff
Posts: 9091
73
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic