• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

convert existed database to record store

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to convert my database or my cvs or my text file to record store?
So I don't need to create it manually in my midp program...
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isak,
JavaRanch has naming policy which is strictly enforced. Please read this policy and change your display name if you wish to continue posting here. Thanks.
 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what do you mean create it manually?
please note that you are writing to a device with very limited memory, so you'lll run out of space very quickly if you try importing some large database info into it.
to approximate a database, it is possible to mimic a table with multiple columns in MIDP.
 
Isak Ricky
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh.. My name is really Isak.. so I don't have problem with the naming policy.. Right?
 
Isak Ricky
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think... my existed database is not big...
but I want to convert it automatically to record store...
I want to do this:
I build midlet that read the text file(cvs file) or xml file and automatically build the record store..... I think it is possible, right?
I don't have tried it... because I am still learning how to do it...
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh.. My name is really Isak.. so I don't have problem with the naming policy.. Right?
By "name" we understand "first name and last name". You do have first and last names, don't you? The naming policy asks you to format your displayed name as your first name, a space, and your last name. Please change it here: https://coderanch.com/forums/user/edit
Thank you for your cooperation.
 
a sanjuan
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
records in recordstores have only one field, to which you write an array of bytes, so you cannot actually do a straightforward import (someone correct me if i'm wrong).
however, i read somewheres that one way to approximate a multiple column database table is by packaging the data in a row into a single record. you then read and write to these byte arrays as you would in a database. it's getting late, so i'll look it up and post the reference/code tomorrow.
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can
1. Put your data in a CSV file (or any format as long as you can read it and parse it);
2. Pack the file in your MIDsuite JAR file;
3. In your MIDlet constructor (or the startApp() method, depending on your needs), use java.lang.Class.getResourceAsStream() method to get access to that file;
4. Parse the file in your MIDlet and populate the record store.
You can use a flag in the record store so that you do not repeatly populate it.
Does that answer your question?
 
Isak Ricky
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank's, but I want to ask again...
If it is possible... how big the file so the midlet can read... It is limited in J2METK or MIDP specification?
If yes, what is the max size?
 
a sanjuan
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the size limit is device specific, i think. you should use getSizeAvailable() to get the amount of size available for the recordstore left. one thing you do not want is to suddenly run out of room.
you might want to keep large databases on the server side for cldc/midp
note that there are small footprint databases for cdc.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isak_Ricky,
The naming convention at JavaRanch is a first name, followed by a space, followed by a last name. Isak Ricky is ok, but Isak_Ricky is not. Please replace the underscore with a space. Thanks.
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Isak_Ricky:
Thank's, but I want to ask again...
If it is possible... how big the file so the midlet can read... It is limited in J2METK or MIDP specification?
If yes, what is the max size?


Well, MIDP programs are limited by two sizes: the memory size and the storage size (flash card). Normally the memory size is very small (64kb) but the storage size can be hundreds of kb.
Your file size is limited by the storage size.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is not correct. You put .txt or .cvs file into a /res folder so that the converter pack it together with .jar into a .prc file. And this file has to be installed on the Palm. The problem is that the Palm will not accept such a file beacause it has more than 64K, much much more.
So what to do?
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Hui Morzhovyj:
I think it is not correct. You put .txt or .cvs file into a /res folder so that the converter pack it together with .jar into a .prc file. And this file has to be installed on the Palm. The problem is that the Palm will not accept such a file beacause it has more than 64K, much much more.
So what to do?


Did you say that Palm cannot accept PRC files larger than 64K? This is not right. The MIDP4Palm VM itself is much more than 64K and obviously it installs fine.
 
Hui Morzhovyj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I know and it sounds logical but see what I get while trying to install my application:
---
Could not install the Palm OS file "... .prc" because an out of memory error occured while installing resource 'Rsrc'(10969). It's possible that the reason for this error is because the size of this resource (502964) is larger than the currently allowed maximum of 65505.
---
What does it mean?
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The problem is that the Palm will not accept such a file beacause it has more than 64K, much much more.


I think that's right ... I put a 300K file into the jar to use it as a database and came up with a 800K .prc file. But it keeps saying that "the installation failed" (no more messages - I use pilot-link on a Linux machine). Anything to do with this?
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Hui Morzhovyj:
Yes, I know and it sounds logical but see what I get while trying to install my application:
---
Could not install the Palm OS file "... .prc" because an out of memory error occured while installing resource 'Rsrc'(10969). It's possible that the reason for this error is because the size of this resource (502964) is larger than the currently allowed maximum of 65505.
---
What does it mean?


Intereting! Thanks Hui and Tom for pointing it out. I think it might have been a bug in the MIDP4Palm utility. According to this palm dev document, Palm OS can only handle code sections up to 64KB in size. For large applications, you must divide it into multiple sections.
Obviously, for a large included resource file, MIDP4Palm should have generated a PRC file with multiple code segments and conform to the PalmOS spec.But it failed to do so.
I think you might want to report this to Sun ...
 
Hui Morzhovyj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, we could report this if it helps other developer.
But the problem still exists. What are the possible solutions? Can I, for example, access a .pdb file? I could prepare it before by converting an existing database into a pdb-format. But I didn't find any solution on accessing a pdb by a MIDlet. It should be possible because C, for example, provides this and I don't think Java is less powerful. Is it possible in J2ME?
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Hui Morzhovyj:

But the problem still exists. What are the possible solutions? Can I, for example, access a .pdb file? I could prepare it before by converting an existing database into a pdb-format. But I didn't find any solution on accessing a pdb by a MIDlet. It should be possible because C, for example, provides this and I don't think Java is less powerful. Is it possible in J2ME?


No, you cannot access pdb files from J2ME/MIDP. Remember that pdb is a PalmOS specific thing and J2ME is designed to be cross platform. If it allows you to access pdb, your MIDlet would not be portable to cell phone or non-Palm devices.
One thing you might try is to look at Java-like Palm specific SDKs such as SuperWaba (search it on Google). It allows you to access many Palm specific features using Java syntax. But your program will NOT be portable.
 
Get out of my mind! Look! A tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic