Alan Morehead

Greenhorn
+ Follow
since Feb 11, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Alan Morehead

I had the same question.
In other posts I have read that "The assignment doesn't require the client data to be in sync with the current database"
I don't have anything in my assignment guideline that says anything explicitly either way. I want to keep it as simple and clean as possible, but don't want to be docked points or fail for this reason. I realize that the client data will be stale if there are numerous clients booking and the search data has been sitting there for a while.
Any suggestions from those who have passed??
Thanks,
I got it to work.
I just needed to use in.readByte() instead of an array like the other fields.
Just needed to know I was on the right path.
Thanks again.
Here is my output without skipping 1 byte:
administrators-Computer:~/java/testArea admin$ java test
Magic Cookie = 257, Total Length = 159, NumOF Fields = 7
===================================================================
FieldNameLength = 4, FieldName = name, Field Length = 64
FieldNameLength = 8, FieldName = location, Field Length = 64
FieldNameLength = 4, FieldName = size, Field Length = 4
FieldNameLength = 7, FieldName = smoking, Field Length = 1
FieldNameLength = 4, FieldName = rate, Field Length = 8
FieldNameLength = 4, FieldName = date, Field Length = 10
FieldNameLength = 5, FieldName = owner, Field Length = 8
===================================================================
Palace Smallville 2 Y$150.00 2005/07/27
Castle Smallville 6 Y$220.00 2005/11/19
Excelsior Smallville 4 Y$230.00 2003/02/05
Palace Whoville 6 N$110.00 2005/09/11
Bed & Breakfast & Business Whoville 2 Y$100.00 2005/08/07
Grandview Whoville 6 Y$210.00 2003/06/10
Dew Drop Inn Metropolis 4 Y$240.00 2005/11/17
Excelsior Metropolis 6 Y$140.00 2005/02/28
Pandemonium Pleasantville 4 N$250.00 2004/12/0
2 Dew Drop Inn Pleasantville 6 N$160.00 2005/03/
04 Dew Drop Inn Digitopolis 4 N$190.00 2005/09
/17 Castle Digitopolis 4 N$90.00 2004/0
1/17 Bed & Breakfast & Business Digitopolis 6 Y$250.00 2003/
09/15 Bed & Breakfast & Business Atlantis 4 N$110.00 2003
/09/03 Excelsior Atlantis 6 Y$230.00 200
4/04/05 Grandview Atlantis 4 N$110.00 20
04/05/04 Elephant Inn EmeraldCity 6 Y$110.00 2
003/07/28 Splendide EmeraldCity 6 N$120.00
2003/06/10 Castle EmeraldCity 4 Y$150.00
2003/05/15 Splendide Bali Hai 6 Y$100.0
0 2005/04/06 Pandemonium Bali Hai 4 Y$150.
00 2003/08/01 Grandview Xanadu 6 N$150
.00 2003/08/02 Pandemonium Xanadu 2 N$13
0.00 2004/08/07 Castle Paravel 4 N$2
20.00 2004/09/14 Splendide Paravel 4 N$
110.00 2004/03/14 Palace Hobbiton 4 N
$90.00 2003/09/22 Grandview Hobbiton 4
Y$110.00 2004/01/03 Excelsior Hobbiton 4
N$110.00 2005/06/23 Castle Lendmarch 4
N$140.00 2003/09/17 Pandemonium Lendmarch 6
Y$230.00 2004/05/02 Grandview Lendmarch

And then I skip 1 byte and it lines up fine...

Magic Cookie = 257, Total Length = 159, NumOF Fields = 7
===================================================================
FieldNameLength = 4, FieldName = name, Field Length = 64
FieldNameLength = 8, FieldName = location, Field Length = 64
FieldNameLength = 4, FieldName = size, Field Length = 4
FieldNameLength = 7, FieldName = smoking, Field Length = 1
FieldNameLength = 4, FieldName = rate, Field Length = 8
FieldNameLength = 4, FieldName = date, Field Length = 10
FieldNameLength = 5, FieldName = owner, Field Length = 8
===================================================================
Palace Smallville 2 Y$150.00 2005/07/27
Castle Smallville 6 Y$220.00 2005/11/19
Excelsior Smallville 4 Y$230.00 2003/02/05
Palace Whoville 6 N$110.00 2005/09/11
Bed & Breakfast & Business Whoville 2 Y$100.00 2005/08/07
Grandview Whoville 6 Y$210.00 2003/06/10
Dew Drop Inn Metropolis 4 Y$240.00 2005/11/17
Excelsior Metropolis 6 Y$140.00 2005/02/28
Pandemonium Pleasantville 4 N$250.00 2004/12/02
Dew Drop Inn Pleasantville 6 N$160.00 2005/03/04
Dew Drop Inn Digitopolis 4 N$190.00 2005/09/17
Castle Digitopolis 4 N$90.00 2004/01/17
Bed & Breakfast & Business Digitopolis 6 Y$250.00 2003/09/15
Bed & Breakfast & Business Atlantis 4 N$110.00 2003/09/03
Excelsior Atlantis 6 Y$230.00 2004/04/05
Grandview Atlantis 4 N$110.00 2004/05/04
Elephant Inn EmeraldCity 6 Y$110.00 2003/07/28
Splendide EmeraldCity 6 N$120.00 2003/06/10
Castle EmeraldCity 4 Y$150.00 2003/05/15
Splendide Bali Hai 6 Y$100.00 2005/04/06
Pandemonium Bali Hai 4 Y$150.00 2003/08/01
Grandview Xanadu 6 N$150.00 2003/08/02
Pandemonium Xanadu 2 N$130.00 2004/08/07
Castle Paravel 4 N$220.00 2004/09/14
Splendide Paravel 4 N$110.00 2004/03/14
Palace Hobbiton 4 N$90.00 2003/09/22
Grandview Hobbiton 4 Y$110.00 2004/01/03
Excelsior Hobbiton 4 N$110.00 2005/06/23
Castle Lendmarch 4 N$140.00 2003/09/17
Pandemonium Lendmarch 6 Y$230.00 2004/05/02
Grandview Lendmarch 4 N$170.00 2003/11/12
Using DataInputStream, I have read in the contents of my sample database file. The header says the fields are 64,64,4,1,8,10,8 bytes. So, I do a loop for each record and read in each field with these byte lengths. The print out is off by 1 byte, so I have to skip one byte for it to line up correctly. The specs say the delete field is 1 byte, so I think this is it. My question is, where is the delete byte? At the beginning of the record or end? When I try to read in the byte, it just shows up blank instead of 0 or 1.
(This is how I am reading the data)
byte [] myByteArray = new byte[1];
in.read(myByteArray);
String s = new String(myByteArray);
System.out.println(s);
The DB schema only lists the 7 fields and this is the data file format:
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record
Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block
Data section.
Repeat to end of file:
1 byte "deleted" flag. 0 implies valid record, 1 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