[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

J2ME SQL Query : HOW

Posted on 2007-10-10
5
Medium Priority
?
7,091 Views
Last Modified: 2013-11-24
J2ME Filter Class
=============

Hi, i am a J2SE familiar with web development. I normally will use SQL Statement to query my database.

Now with J2ME's RMS system, i am stuck and lost on querying database.

This is my database structure in RMS.

Year|Month|Day|Expenses_Type|Expenses_Mode|Amount|Remark

 So, i wish to select certain record base on the condition something like this
SELECT * From [table_name] where Year ='XXX' and Month='YYY'

I have able to retrieve the entire record in RMS with this code:
..
..
            recordstore = RecordStore.openRecordStore("database_name", true);
            byte[] byteInputData = new byte[500];
            ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
            DataInputStream inputDataStream = new DataInputStream(inputStream);

            for (int x = 1; x <= recordstore.getNumRecords(); x++) {
                recordstore.getRecord(x, byteInputData, 0);
                input_id = inputDataStream.readInt();
                input_year = inputDataStream.readUTF();
                input_month = inputDataStream.readUTF();
                input_type = inputDataStream.readUTF();
           }
..
..

I have also read the J2ME Filter in here http://www.java2s.com/Code/Java/J2ME/Demonstratessimplerecordsortingandfiltering.htm 
and i notice it's only able to search a single phrase or column only. So, not able to match what i want.

Thus, this is my question.

1. How can i preform similar operation (SELECT Query) in J2ME RMS database? Is there any other way for me to achieve the above SQL statement?
2. The Filter option from J2me, am i right that it's only useful when you wish to search a single text ONLY?
3. Can you suggest any other useful URL for my as a reference code? I am a beginner in J2ME and notice it's kind of "restricted" as mostly many classes is not available.

Thank you.

0
Comment
Question by:taiping
5 Comments
 
LVL 5

Assisted Solution

by:qasitouch
qasitouch earned 600 total points
ID: 20145707
dear. RMS is not the RELATIONAL DATABASE.

anyways i tel you about how u can handel the record in RMS.

 its just a simple way to store your data in mobiles.
each transaction is stores as a record in RMS, which is stors like , u can say list or array:P (because it has no rows and cols).
and there are no sql queries supported in j2me.


your must read the record (rms) and then find compare that with your required string/data.

hope you have the solution to your problem.

one more thing, there is a size limitation of RMS, which varies from phone to phone and available memory.

Kind Regards,
qasitouch.
0
 
LVL 12

Accepted Solution

by:
keyurkarnik earned 300 total points
ID: 20175542
You will not be able to run SQL statements in J2ME on the RecordStore. THe recordstore only stores all the data as separate records.
You need to formulate a way to store all the data (which means that you could either store each tuple in your db as separate rows, or you could store all of them in a single record).

You will need to implement the complete mechanism to read (and write) all the bytes from the recordstore, interpret them as required and then use the data. You can even skip the RecordFilter and do it yourself.

It makes more sense to build something like a DAO (Data Access Object) and store the object. The object will internally have store() and read() methods which will know how to write to and read from the RecordStore.
0
 
LVL 5

Assisted Solution

by:qasitouch
qasitouch earned 600 total points
ID: 20176135
here is the example,

http://www.microjava.com/articles/techtalk/rms2

you will come to know how you can play with RMS in j2me and use it for your purposes.

kind Regards,
qasitouch.
0
 
LVL 15

Assisted Solution

by:jimmack
jimmack earned 300 total points
ID: 20276992
If you're still looking for a solution to this and you really want to use SQL, you could try Pointbase

http://www.pointbase.com/products/core_technology.aspx

I haven't personally used it, but the datasheet describes some quite impressive features and they do have an evaluation version available.

Jim.
0
 

Assisted Solution

by:step2ME
step2ME earned 300 total points
ID: 20410381
DataMirror company provides PointBase Micro database for J2ME http://www.pointbase.com/products/micro.aspx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question