• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getBytes() urgent ????????

 
Gurpreet Saini
Ranch Hand
Posts: 295
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi reader,
I had fixed my deprecated String class constructor by using this following signature
new String(byte[], int, int);
But I am having a problem in using getBytes() method . Whenever, I book the seats on particular filght that record is skipped for ever. I do not understand why this happens ?. Please comply as soonas possible.
Thank you,
:roll:
 
Ron Newman
Ranch Hand
Posts: 1056
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post some code that demonstrates the problem?
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gurpreet,
I don't think it has to do with the readRecord at all. It probably has to do with how you built your DataInfo that was passed into the modify method on Data. Be sure that LIVE_RECORD is set on the DataInfo or the record will be skipped.
Hope this helps,
Michael Morris
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
This is the code which skips the record on which modification of avalable seats is done:

int size, space, toCopy;
byte [] buffer = new byte[recordLen];
buffer[0] = LIVE_RECORD;
int offset = 1;
for (int i = 0; i < description.length; i++)
{
space = description[i].getLength();
// size = newData[i].length();
// toCopy = (size <= space) ? size : space;
newData[i].getBytes();
offset += space;
}
db.write(buffer);
}
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gurpreet,
You're not copying the bytes into buffer.
You should have something like:

Also, you should uncomment the "size = ..." and "toCopy = ..." lines.
Hope this helps,
Michael Morris
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Morris,
I thank you, for your help. Now, it is functioning properly. Morris did your policy granted "all permissions" or it supplied certain parameters ?. Second, If I implement lock / unlock in Data class then does it mean that I am modifying Data class. This I am asking because my DataAccess class is extending Data class. Or shall I implement my lock / unlock in DataAccess class ?.
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gurpreet,

Morris did your policy granted "all permissions" or it supplied certain parameters ?.

Yes.

Second, If I implement lock / unlock in Data class then does it mean that I am modifying Data class. This I am asking because my DataAccess class is extending Data class. Or shall I implement my lock / unlock in DataAccess class ?.

I would say no, but it would probably be better to implement them in the child class from a pure design point of view, otherwise why subclass Data in the first place?
Hope this helps,
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic