This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Database update problem URLybird Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Database update problem URLybird" Watch "Database update problem URLybird" New topic
Author

Database update problem URLybird

Naveen Narayanan
Ranch Hand

Joined: Sep 11, 2007
Posts: 114

I had a problem with the db-1x2.db while updating the filed "size"(Maximum occupancy) .
4 bytes I can see in the hex editor as 32 20 20 20 for a value 2
when I write it back , it becomes 00 01 34 20 for a value 4
I think it should be 34 20 20 20


I have used
dbFile.writeUTF(new Integer(size).toString()); for writing
and


dbFile.readFully(input);
String str = new String(input, offset, length, "UTF-8"); for reading


Is there any byte alignment thing working here , or going to show some indifferent behavior later ?


SCJP 5.0, SCJD, SCWCD
Anne Crace
Ranch Hand

Joined: Aug 29, 2005
Posts: 223
Try changing your 4th argument to "US-ASCII" for the read operation. Hope this helps.


SCJP, SCJD
 
Consider Paul's rocket mass heater.
 
subject: Database update problem URLybird
 
Similar Threads
The max input fields for servlet can handle
java.lang.VerifyError:
in which method shuld i use at the servlet code for request
hashcodes
jsp insert program not working