• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help plz why am i getting this exception

 
shobhit garg
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i'm doin a school project in j2me
i have develop a address book for the mobile phone
heres where i have got stuck this simple peice of code to browse the address boook is throwing an exception i don't know why..
plz help

public int enumerateContacts(String [] contacts)//string[] is passed by reference send names in array contacts
{String dummy;
int x=0;

try{
numOfRec=rs.getNumRecords();
contacts=new String[numOfRec];
for( x=1;x<=numOfRec;x++)
{dummy=new String (rs.getRecord(x));
System.out.println("dummy created" + dummy);
contacts[x-1]=getName(dummy);
System.out.println("name added"+contacts[x-1]);
}}
catch(Exception e){ //<-----why is exception being generated
System.out.println("error "+e.getMessage());
}
return x-1;
}


on running the application i get the foll output on the wtk console:

dummy createdname=CATHYcompany=IBMtitle=CFOadd1=BOSTONadd2=FLORIDAphone=78542996email=
name addedCATHY
error null ------->exception


i ideally all the records in the record store should have been shown in the console
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help if you'd do a "e.printStackTrace()" in the catch block and post the stack trace for us to see.
 
shobhit garg
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lasse Koskela:
It would help if you'd do a "e.printStackTrace()" in the catch block and post the stack trace for us to see.


here's what i got on doing e.printStackTrace

Could not create icon com.sun.midp.midlet.Selector$MIDletInfo@a9179cchk pnt 1
dummy createdname=CATHYcompany=IBMtitle=CFOadd1=BOSTONadd2=FLORIDAphone=78542996email=
name addedCATHY
error null
**Dummy PrintStackTrace**

plz help
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And from which line in your code is the exception thrown?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic