Need HELP for MIDP application.

i was having problems in row 45-70 and from row 88-105 which im not so sure weither i write it correctly or not.

i wanted to do an application using MIDP where user can view question and chose the answer using List.

The question can be get from database and the answer chose are needed to be written in text file.

======================================================import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

publicclass NotSoSimpleFaceextends MIDletimplements CommandListener

{

private Display display;

private Command exit;

private Command next;

private Command finish;

private List list;

privateint QNo=1;

public NotSoSimpleFace()

{

display = Display.getDisplay(this);

}

publicvoid startApp()

{

Question(QNo);

}

publicvoid pauseApp()

{

}

publicvoid destroyApp(boolean unconditional)

{

notifyDestroyed();

}

publicvoid commandAction(Command command, Displayable Displayable)

{

if (command == next)

{

boolean choice[] =newboolean[list.size()];

list.getSelectedFlags(choice);

for (int x = 0; x < 4; x++)

{

if (choice[x])

{

System.out.println(list.getString(x));

//Write to Text File in Append Mode

//..."//root1/answer.txt;append=true", Connector.WRITE

OutputConnection connection = (OutputConnection)

Connector.open("file:///root1/answer.txt; append=true" Connector.WRITE );

OutputStream out = connection.openOutputStream();

PrintStream output =new PrintStream( out );

output.println("Answer 1 is:" + list.append(x));

output.println("Answer 2 is:" + list.append(x));

output.println("Answer 3 is:" + list.append(x));

output.println("Answer 4 is:" + list.append(x));

out.close();

connection.close();

Alert alert =new Alert("Completed","Data Written", null,null);

alert.setTimeout(Alert.FOREVER);

alert.setType(AlertType.ERROR);

display.setCurrent(alert);

}

}

QNo+=1;

if (QNo <= 4){

Question(QNo);

}else{

destroyApp(true);

}

}

elseif (command == exit)

{

destroyApp(true);

}

}

privatevoid Question(int no)

{

String url ="jdbc:odbc:MyODBC";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection c = DriverManager.getConnection(url,"","");

Statement s = c.createStatement();

ResultSet rs = s.executeQuery ("select Question from Question");

while (rs.next())

{

FileOutputStream fout =new FileOutputStream("sample.txt");

PrintStream myOutput =new PrintStream(fout);

list =new List( myOutput.print(rs.getString(1) +"\t") + no, List.MULTIPLE);

list.append("A",null);

list.append("B",null);

list.append("C",null);

list.append("D",null);

exit =new Command("Exit", Command.EXIT, 1);

if (no == 4){

next =new Command("Finish", Command.EXIT, 2);

}else{

next =new Command("Next", Command.EXIT, 2);

}

list.addCommand(exit);

list.addCommand(next);

list.setCommandListener(this);

display.setCurrent(list);

}

}

}

[6708 byte] By [Shahiraa] at [2007-11-27 4:26:16]
# 1
What exactly is your problem? And there's no point mentioning the row numbers since we can't see them here now, can we? You should've marked out the relevant parts using comments at least.
nogoodatcodinga at 2007-7-12 9:34:42 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

Ok, I haven't really worked much with files in J2ME and I haven't worked with MIDP 2.0 at all, but I'm fairly certain that there is no JDBC available in CLDC. If you're programming for a mobile phone then you can't use SQL. It's only available for CDC

You're on the right track with the Connector; explore that further.

But not every phone has a filesystem; keep that in mind. Some only expose an RMS for data storage to MIDlets.

Message was edited by:

nogoodatcoding

nogoodatcodinga at 2007-7-12 9:34:42 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
your code cannot work...ResultSet are not available in MIDP! http://developers.sun.com/techtopics/mobility/allarticles/#wsand more on google
suparenoa at 2007-7-12 9:34:42 > top of Java-index,Java Mobility Forums,Java ME Technologies...