Hi, I just started the SCJD, I have a question on connecting the database file. First I tried to just look at the content in the db file, but since this database is a non-relational, no table name and cannot be open in any DBMS I got, I realised JDBC and SQL statements cannot be used. So I open it in the normal file handling way, using FileInputStream, and I have got the content out from the file. But when I display the content of the db file onto the scream, it is so unorganised and some data cannot be read and replaced by weird symbols on the screen, so it must not totally read this file correctly according to its format. I wonder am I using the right approach to read to this db file? I appreciate for any comments and advices, thank you very much.
Hello Alex, Does your specs say anything about the format of the db file? Your assignment might be different, than mine for example, but from my specs I know how to read the size of each record field from the file and then the record field itself. Regards, Seid
Hi, the format of the database file is actually: .db I have got a little more progress on reading the file, I will briefly list what I did: 1. I read the .db file with RandomAccessFile or FileInputStream 2. According to the format of the Start of file section in the assignment spec, there are 4 bytes for magic cookie, 4 bytes for overall length for each record, and 2 bytes for number of fields. So I have create an array for each of these 'things', total of 3. To see what values they are, I first put the correct bytes into each array. 3. The 3 arrays now contains the bytes, then I convert them into string and display them on screen. The result is not useful at all, looks like '2 faces icon' and a 'f' sign, I do know that probably is because it is not text for display but just some information. But I do know you will need to know the overall length of each field to work out the position of each record in the .db file, but I cannot retrieve such infomation using this approach. There are other problems when I just display everything of the .db file on screen, a field of data seems to be missing - location. Also there is no 'owner' for the very last record. Mmm... many problems here for me, anybody else also having trouble like this? I appreciate for any comments and advises. Thank you.