| | |
problem in retrieving data via RMS
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2009
Posts: 47
Reputation:
Solved Threads: 2
hi friends...
I have Written some codes for adding and retrieving data from RMS:
but when i run it , instead of my record i see this error :
I have Written some codes for adding and retrieving data from RMS:
Java Syntax (Toggle Plain Text)
public void commandAction(Command command, Displayable displayable) { if(command==exit) { destroyApp(true); notifyDestroyed(); } else if(command==start) { try { recordstore=RecordStore.openRecordStore("My RecordStore",true); } catch(Exception error) { alert=new Alert("Error Creating",error.toString(),null,AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { String outPutData[]={"Mary","Bob","Adam"}; for(int x=0;x<3;x++) { byte[] byteOutPutData=outPutData[x].getBytes(); recordstore.addRecord(byteOutPutData,0,byteOutPutData.length); } } catch(Exception error) { alert=new Alert("Error Waiting",error.toString(),null,AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { byte[] byteInputData=new byte[1]; int length=0; for(int x=1;x<=recordstore.getNumRecords();x++) { if(recordstore.getRecordSize(x)>byteInputData.length) { byteInputData=new byte[recordstore.getRecordSize(x)]; } length=recordstore.getRecord(1,byteInputData,0); } alert = new Alert("Reading", new String(byteInputData, 0,length), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } catch (Exception error) { alert = new Alert("Error Reading", error.toString(),null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { recordstore.closeRecordStore(); } catch (Exception error) { alert = new Alert("Error Closing", error.toString(),null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } if (RecordStore.listRecordStores() != null) { try { recordstore.deleteRecordStore("MY RecordStore"); } catch (Exception error) { alert = new Alert("Error Removing", error.toString(),null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } } } }
but when i run it , instead of my record i see this error :
Java Syntax (Toggle Plain Text)
public void commandAction(Command command, Displayable displayable) { if(command==exit) { destroyApp(true); notifyDestroyed(); } else if(command==start) { try { recordstore=RecordStore.openRecordStore("My RecordStore",true); // LINE 1 } catch(Exception error) { alert=new Alert("Error Creating",error.toString(),null,AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { String outPutData[]={"Mary","Bob","Adam"}; for(int x=0;x<3;x++) { byte[] byteOutPutData=outPutData[x].getBytes(); recordstore.addRecord(byteOutPutData,0,byteOutPutData.length); } } catch(Exception error) { alert=new Alert("Error Waiting",error.toString(),null,AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { byte[] byteInputData=new byte[1]; int length=0; for(int x=1;x<=recordstore.getNumRecords();x++) { if(recordstore.getRecordSize(x)>byteInputData.length) { byteInputData=new byte[recordstore.getRecordSize(x)]; } length=recordstore.getRecord(1,byteInputData,0); } alert = new Alert("Reading", new String(byteInputData, 0,length), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } catch (Exception error) { alert = new Alert("Error Reading", error.toString(),null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { recordstore.closeRecordStore(); } catch (Exception error) { alert = new Alert("Error Closing", error.toString(),null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } if (RecordStore.listRecordStores() != null) { try { recordstore.deleteRecordStore("MY RecordStore"); // LINE 2 } catch (Exception error) { alert = new Alert("Error Removing", error.toString(),null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } } } }
Check "Line 1" and "Line 2" tags.
"My RecordStore" and "MY RecordStore" both are different names.
Theres no RS with name "MY RecordStore". Thats why its showing error.
Regards,
Puneet Kalra
www.PuneetK.com
Sun Certified Java Programmer
Admin of Pikk - Object Relational Mapping Framework
www.PuneetK.com
Sun Certified Java Programmer
Admin of Pikk - Object Relational Mapping Framework
![]() |
Similar Threads
- retrieving data from sqlserver2000 in tree structure in jsp (JSP)
- retrieving data from MySQL (PHP)
- Problem with retrieving data from access 2003 (Visual Basic 4 / 5 / 6)
- problem with entering data in datagrid (VB.NET)
- VB.Net: Problem Retrieve data from ListView (VB.NET)
- retrieving "Data" from Listbox (VB.NET)
Other Threads in the Java Forum
- Previous Thread: How to locate image at different location in Jpanel
- Next Thread: Making a Java Key Logger
| Thread Tools | Search this Thread |
Tag cloud for Java
affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth businessintelligence chat class classes client code component database desktop draw ebook eclipse encode equation error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer intersect j2me java javaexcel javaprojects jmf jni jpanel julia linked linux list loop mac main map method methods mobile netbeans newbie number object open-source oracle parameter print problem program programming project properties recursion reference replaysolutions rotatetext scanner score screen scrollbar server set size sms socket sort sql string superclass swing template test threads time tree windows working xstream





