943,607 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 377
  • Java RSS
Aug 30th, 2009
0

problem in retrieving data via RMS

Expand Post »
hi friends...
I have Written some codes for adding and retrieving data from RMS:
Java Syntax (Toggle Plain Text)
  1. public void commandAction(Command command, Displayable displayable) {
  2. if(command==exit)
  3. {
  4. destroyApp(true);
  5. notifyDestroyed();
  6. }
  7. else if(command==start)
  8. {
  9. try
  10. {
  11. recordstore=RecordStore.openRecordStore("My RecordStore",true);
  12. }
  13. catch(Exception error)
  14. {
  15. alert=new Alert("Error Creating",error.toString(),null,AlertType.WARNING);
  16. alert.setTimeout(Alert.FOREVER);
  17. display.setCurrent(alert);
  18. }
  19. try
  20. {
  21. String outPutData[]={"Mary","Bob","Adam"};
  22. for(int x=0;x<3;x++)
  23. {
  24. byte[] byteOutPutData=outPutData[x].getBytes();
  25. recordstore.addRecord(byteOutPutData,0,byteOutPutData.length);
  26. }
  27. }
  28.  
  29. catch(Exception error)
  30. {
  31. alert=new Alert("Error Waiting",error.toString(),null,AlertType.WARNING);
  32. alert.setTimeout(Alert.FOREVER);
  33. display.setCurrent(alert);
  34. }
  35. try
  36. {
  37. byte[] byteInputData=new byte[1];
  38. int length=0;
  39. for(int x=1;x<=recordstore.getNumRecords();x++)
  40. {
  41. if(recordstore.getRecordSize(x)>byteInputData.length)
  42. {
  43. byteInputData=new byte[recordstore.getRecordSize(x)];
  44. }
  45. length=recordstore.getRecord(1,byteInputData,0);
  46. }
  47. alert = new Alert("Reading", new String(byteInputData, 0,length), null, AlertType.WARNING);
  48. alert.setTimeout(Alert.FOREVER);
  49. display.setCurrent(alert);
  50.  
  51.  
  52. }
  53. catch (Exception error)
  54. {
  55. alert = new Alert("Error Reading", error.toString(),null, AlertType.WARNING);
  56. alert.setTimeout(Alert.FOREVER);
  57. display.setCurrent(alert);
  58. }
  59. try
  60. {
  61. recordstore.closeRecordStore();
  62. }
  63. catch (Exception error)
  64. {
  65. alert = new Alert("Error Closing", error.toString(),null, AlertType.WARNING);
  66. alert.setTimeout(Alert.FOREVER);
  67. display.setCurrent(alert);
  68. }
  69. if (RecordStore.listRecordStores() != null)
  70. {
  71. try
  72. {
  73. recordstore.deleteRecordStore("MY RecordStore");
  74. }
  75. catch (Exception error)
  76. {
  77. alert = new Alert("Error Removing", error.toString(),null, AlertType.WARNING);
  78. alert.setTimeout(Alert.FOREVER);
  79. display.setCurrent(alert);
  80. }
  81. }
  82. }
  83. }

but when i run it , instead of my record i see this error :
Attached Thumbnails
Click image for larger version

Name:	Error.JPG
Views:	24
Size:	12.7 KB
ID:	11400  
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
Dajer is offline Offline
53 posts
since Jul 2009
Aug 30th, 2009
1

Re: problem in retrieving data via RMS

Java Syntax (Toggle Plain Text)
  1. public void commandAction(Command command, Displayable displayable) {
  2. if(command==exit)
  3. {
  4. destroyApp(true);
  5. notifyDestroyed();
  6. }
  7. else if(command==start)
  8. {
  9. try
  10. {
  11. recordstore=RecordStore.openRecordStore("My RecordStore",true); // LINE 1
  12. }
  13. catch(Exception error)
  14. {
  15. alert=new Alert("Error Creating",error.toString(),null,AlertType.WARNING);
  16. alert.setTimeout(Alert.FOREVER);
  17. display.setCurrent(alert);
  18. }
  19. try
  20. {
  21. String outPutData[]={"Mary","Bob","Adam"};
  22. for(int x=0;x<3;x++)
  23. {
  24. byte[] byteOutPutData=outPutData[x].getBytes();
  25. recordstore.addRecord(byteOutPutData,0,byteOutPutData.length);
  26. }
  27. }
  28.  
  29. catch(Exception error)
  30. {
  31. alert=new Alert("Error Waiting",error.toString(),null,AlertType.WARNING);
  32. alert.setTimeout(Alert.FOREVER);
  33. display.setCurrent(alert);
  34. }
  35. try
  36. {
  37. byte[] byteInputData=new byte[1];
  38. int length=0;
  39. for(int x=1;x<=recordstore.getNumRecords();x++)
  40. {
  41. if(recordstore.getRecordSize(x)>byteInputData.length)
  42. {
  43. byteInputData=new byte[recordstore.getRecordSize(x)];
  44. }
  45. length=recordstore.getRecord(1,byteInputData,0);
  46. }
  47. alert = new Alert("Reading", new String(byteInputData, 0,length), null, AlertType.WARNING);
  48. alert.setTimeout(Alert.FOREVER);
  49. display.setCurrent(alert);
  50.  
  51.  
  52. }
  53. catch (Exception error)
  54. {
  55. alert = new Alert("Error Reading", error.toString(),null, AlertType.WARNING);
  56. alert.setTimeout(Alert.FOREVER);
  57. display.setCurrent(alert);
  58. }
  59. try
  60. {
  61. recordstore.closeRecordStore();
  62. }
  63. catch (Exception error)
  64. {
  65. alert = new Alert("Error Closing", error.toString(),null, AlertType.WARNING);
  66. alert.setTimeout(Alert.FOREVER);
  67. display.setCurrent(alert);
  68. }
  69. if (RecordStore.listRecordStores() != null)
  70. {
  71. try
  72. {
  73. recordstore.deleteRecordStore("MY RecordStore"); // LINE 2
  74. }
  75. catch (Exception error)
  76. {
  77. alert = new Alert("Error Removing", error.toString(),null, AlertType.WARNING);
  78. alert.setTimeout(Alert.FOREVER);
  79. display.setCurrent(alert);
  80. }
  81. }
  82. }
  83. }

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,
Reputation Points: 51
Solved Threads: 24
Junior Poster
puneetkay is offline Offline
122 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: How to locate image at different location in Jpanel
Next Thread in Java Forum Timeline: method in java application





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC