Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FBN: Data.writeRecord errors

 
Karthik Jayaprakasham
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the writeRecord(String[] newData) method in Data does not seem to be writing records properly to the file system. For example if i edit from a GUI the number of seats available for the record
SA001SFODENSpeedyAir400Sun13:4020m50 (from 50 available seats to 48)
what gets written is
4801SFODENSpeedyAir400Sun13:4020m50
As you can see its changing the first few chars with 48 instead of changing the last ones which represents the seat number.
I have checked the length of data that I sent to this method and it's 61 and the length of a record in the db is also 61..
So I don't know whats wrong...
Any suggestions?
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karthik,
My recommendation is to make the database methods as general as possible. That is to say, follow the comments from the Sun interface. For example, the following code should work correctly.

In other words, the read record should read each field in the record and return each field as an element of the array. Conversely, the write record should write each field in the record array parameter to the database. It appears that your writeRecord is just writing a single field to the database. It should be writing each of the fields in the record array to the database.
For example,
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George,
This is the FBNS assignment - there is no interface to implement. However it has different "challenges" for the coder .
Regards, Andrew
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karthik,
Is this problem before or after you replaced the deprecated code?
You might want to try adding some logging in the writeRecord method so that you can see what the contents of the buffer is just before you try and write it.
Something sounds very wrong, as you should be writing an entire record, so even if you failed to populate the intermediate buffer correctly, you should still overwrite the entire record with nulls. It sounds more like you are only writing the last String from your input parameters rather than writing the intermediate buffer.
Regards, Andrew
 
Ian Roberts
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have just recently submitted the FBNS assignment and have not had a similar problem. Apart from the deprecated code there is nothing to change in the DAO IO methods.
There is definitely something wrong and I would recommend you checked your present class definition against that of the original downloaded source. It may be something that you accidentally applied or something that has changed that was not required.
Its great to hear from someone who is also completing the FBNS assignment. I thought I was the only one! I must have been one of the last people to download the assignment because a friend downloaded one of the new assignments just days after.
Ian R.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic