Chandrasekaran Sathasivam

Greenhorn
+ Follow
since Dec 29, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chandrasekaran Sathasivam

Hi friends,
I've got error while retrieving records from RMS, after deleting a record in it. The error message is that InvalidRecordID exception.
My doubt is, after deleting a record in RMS, how can we retrieve records. Say for example, an RMS contains five records. I just delete 3 record. Upto this everying goes fine. But while retrieving remaining records after deletion, now it shows only first two records. Remaining two records are not displayed and it shows the above error message.
I hereby included the source code for the deletion application. Kindly give your idea regarding the same.
Expecting for your response,
Chandru
------------------------------------------------
Here you have to give input as any data and store them by clicking menu command and select Add option in it. If you select Retrieve command it will show the records in RMS. To delete a record say 3, you just give input as 3 and select Delete option from Menu command. Now it will delete 3rd record successfully.
But, if you try to retrieve remaining records now only first two records will be displayed and while accessing third record you will be getting error.
Here is the code.
------------------------------------------------
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
public class RSDelete extends MIDlet implements CommandListener
{
private Command retrieveCommand;
private Command okCommand;
private Command deleteCommand;
private Display display;
private TextBox t = null;
String dbn=new String("Sample");
RecordStore rs=null;
int currpos,maxchar;
public RSDelete()
{
display = Display.getDisplay(this);
retrieveCommand = new Command("Retrieve", Command.OK, 2);
okCommand = new Command("Add", Command.OK, 2);
deleteCommand = new Command("Delete", Command.OK, 2);
t = new TextBox("Enter your data :", "",256, 0);
t.addCommand(retrieveCommand);
t.addCommand(okCommand);
t.addCommand(deleteCommand);
t.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(t);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable s)
{
try
{
if(c == okCommand)
{
rs=RecordStore.openRecordStore(dbn,true);
String name = "";
name=new String(t.getString());
byte[] data=name.getBytes();
rs.addRecord(data,0,name.length());
System.out.println(" Record is updated");
rs.closeRecordStore();
}
if(c == deleteCommand)
{
rs=RecordStore.openRecordStore(dbn,true);
int id = Integer.parseInt(t.getString());
int totalRecords = rs.getNumRecords();
boolean flag = false;
for(int i = 1; i <= totalRecords; i++)
{
if(i == id)
{
rs.deleteRecord(id);
flag = true;
break;
}
}
if(flag)
System.out.println("record :"+id+" is deleted ");
else
System.out.println("No match found");
rs.closeRecordStore();
} /* end of Add command */
if(c == retrieveCommand)
{
rs=RecordStore.openRecordStore(dbn,true);
String result = "";
byte[] data = null;
System.out.println("Rows in the rs are :");
System.out.println("records in rms :"+rs.getNumRecords());
int totalRecords = rs.getNumRecords();
for(int i = 1; i <= totalRecords; i++)
{
data = rs.getRecord(i);
result = new String(data);
System.out.println(i+": " + result);
}
rs.closeRecordStore();
}
}catch(RecordStoreException e)
{
System.out.println(" Error :"+e);
}
} /* end of command Action */
} /* end of class */
-----------------------------------------------------------


22 years ago
Hi,
I've implemented simple shopping model in J2ME application. What are all the Modifications I should to do in that application, so that it can run in PALMOS?
Thanks in advance
chandru
22 years ago
Hai,
While storing the record in the localdatabase using the RecordStore class, can we have more than one field in the record. I'm able to store the record which is nothing but a field or data.
How many number of RecordStore can we create in the MIDlet at the maximum normally?
Whether memory used for the RecordStore database is depends on the number of records available in the database or fixed for each database ?
I'm using Java2 Wireless Toolkit for running the application.

Answers from anybody will be great help for me.
With regards
Chandru
23 years ago
Hai Luis,
Thanks for your response. I've done the connection from the client to server using the Servlet already. But here we need that the prerequirement that Java Web Server should run on server side.
Is there any other way to communicate with the server, so that we can retrieve data from the server side, may be a text file.
With regards
Chandru
23 years ago
Hello Mr.Eric,
Could you please explain more about application environment. I did not catch your point regarding the explanation that you gave for the difference between J2ME and WAP.
Expecting for your depth information.
23 years ago
Hello,
I am using the notepad as editor for creating and Java2 Wireless Toolkit for running the J2ME application. Could anybody help me, how to connect the application to the HttpServer and read text file that's available in the remote HttpServer?
With regards
Chandru
23 years ago
Hay,
Thanks all guys. I've got the result for calling applet from servlet. It perfectly works by placing codebase attribute with applet tag, that what sunilkumar told. Once again I thank to all guys response my request.
With regards
Chandru
23 years ago
Hai,
I've done what u say. ie., placing applet file in another directory. But still the same problem exists.
I've put my applet in c:\javasrc dir. and change the href attribute of base tag as c://javasrc.
Could u help me.
With regards
Chandru
23 years ago
Hai,
Consider the following coding. It's concerned with calling an applet from servlet.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Helloser extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
PrintWriter out=res.getWriter();
out.println("<html><head><h1>Hello World</h1>");
out.println("<base href=\"c:\\servlet\"></head>");
out.println("<applet code=hello.class height=400 width=400>");
out.println("</applet></html>");
out.close();
}
}
Here hello.class is the compiled code of the hello.java applet file, which is available in the directory c:\servlet. I've used servletrunner, jsdk application for this program. I've specified the address to see the page in browser like,
http://localhost:8080/servlet/Helloser
it calls the Helloser servlet and while loading hello applet class, it says that hello class not found. Here Helloser.java is the servlet file name available in the c:\servlet directory.
What is wrong in the above code? Please explain.
With regards
Chandru
23 years ago
Hai guys,
Thanks for ur response. But both the replies didn't help me. I've specified the path like c:/servlet. But browser says the same error that class file not loaded.
For the second reply the link http://www.mycgiserver.com/servlet/smallalley.smallcon.jshitcounter.userlogin hasn't connected.
Could any body help me? What happen Mr.Bill?
With regards
Chandru
23 years ago
Hello Mr.Bill,
Regarding ur explanation about base tag, could u explain how to specify href attribute tag value if my applet class file is available in the directory say c:\servlet.
I've tried like this
<base href=c:\servlet>
But the browser doesn't load the applet class file and says that class file not found.
I'm very happy if u will explain the solution for this problem.
With regards
Chandru
23 years ago