File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes modify method in Data Class 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 "modify method in Data Class" Watch "modify method in Data Class" New topic

modify method in Data Class

raphael Bereh
Ranch Hand

Joined: Jan 15, 2002
Posts: 79
In the FBN assignment I am trying to use the method public synchronized void modify(DataInfo newData) in the Data Class but it does not write the data as expected. The record writen is blank
Has Anyone used the method successfully ?

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17249

Have you checked the DataInfo class that you are passing in to the modify method. Check to see that is has values in it. Put System.outs in the modify method that will print the values of the DataInfo class that you pass.
Also did you change the deprecated method in the writeRecord method? This could also be important how you fixed it. I remember having a problem saving too, and I found that my solution to the deprecated method wasn't quite right.

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
ravindra janapreddy
Ranch Hand

Joined: Jan 30, 2001
Posts: 84
I have the similar problem after invoking the modify method a blank record is being written to the db file. I have printed out the DataInfo object using System.out.println and it has all the values.
Please resolve the issue.

Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
Looks like it has something to do with deprecated line in writeRecord() method.
ravindra janapreddy
Ranch Hand

Joined: Jan 30, 2001
Posts: 84
Hi Sai
This is my fix for the deprecated line. Is it wrong ?
for (int i = 0; i < description.length; i++) {
space = description[i].getLength();
size = newData[i].length();
toCopy = (size <= space) ? size : space;
//newData[i].getBytes(0, toCopy, buffer, offset);
String enc = "ISO-8859-1";
newData[i].getBytes( enc );
offset += space;
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
Yes. You are missing two steps.
You need to figure out how much of newData[i] is to be converted to byte[].
Also you need to populate/copy the buffer[] with the above value.
Default encoding should be fine.
I agree. Here's the link:
subject: modify method in Data Class
Similar Threads
Passed with 152/155 (98%)
problem with book seats
add, delete and modify
client id generation.
The question about LOCK,UNLOCK method