Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
I am completly confuse about the way to read the database. I have been given a binary database from sun and I don't know how to read it . Here are a few points where I need some clarification: 1) I assume that I have to read this database without recreating an other one. 2) here is how I tried to access it : I can red short, long but not the string or char for name, nocation etc....
this does not work!
this does not work either!!!
I also tried RandomAccessFile without any success... There is something that i am missing about reading strings or char..... 3) the other question I have concern serialization. At first I was thinking of reading the file with ObjectInputStream to have it serialized but this is not possible because it has not been created this way... How do I get it serialized? One way would be to store what I just read ( assuming I find out how) in an object let say Contracor which implement seializable... Can you help me on this . I am stucked Thank you Lydie
Hi Lydie, 1. Hopefully you made a backup copy of your Sun-supplied db file and you're keeping it in a safe place. You will need to make a copy of this original db file if you corrupt the one you're using in development and testing. Also, you have to submit an unchanged original copy of your db file when you submit your project. 2. I recommend using RandomAccessFile because of its ability to seek to a particular location in the file (this will come in very handy later as you implement the Data class). 3. You're correct. You should use the Sun-supplied db file as is, without converting it into any other format. 4. Look at the database file format specified in your assignment instructions carefully.
You should be reading: magic cookie, # of fields, length of first schema field name, first schema field name, length of first schema field, length of second schema field name, second schema field name, length of second schema field name, length of third... Instead of reading: magic cookie, # of fields, length of first schema field name, length of second schema field name, length of third schema field name, length of fourth schema field name, ... In other words the repeating block in the database schema section is: length of field name, field name, length of field, 5. Take a look at this, it may give you an idea of one way to read a string field from the database file: