Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (483)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  MIdlet and MS Access  (Read 2044 times)
0 Members and 1 Guest are viewing this topic.
Offline beyonder

Junior Newbie




Java games rock!


« Posted 2004-03-20 12:28:45 »

hi can someone tell me how to access a MS access db using a midlet?  
Offline beyonder

Junior Newbie




Java games rock!


« Reply #1 - Posted 2004-03-23 10:32:46 »

can some one reply please doesn't anyone know?
Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #2 - Posted 2004-03-23 14:05:20 »

Have you searched around at all?

I have no idea about accessing databases, (in J2ME or otherwise) however, 1 google search told me that JDBC is the Java API for such tasks, and that it is built upon J2SE.

I doubt very much there is a version of it that will run on J2ME, but I could be mistaken.

MIDlets in general run on resource constrained devices.
Databases in general are used when dealing with large volumes of data.
I don't see how the 2 could, or would need to, go together.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline caraiz

Senior Newbie




Java games rock!


« Reply #3 - Posted 2004-03-23 14:22:12 »

i dont know what exactly u wish do, but i think the only solution is call to a jsp, asp,...  to receive the data from the database

Offline shareme

Junior Member




Java games rock!


« Reply #4 - Posted 2004-03-23 17:55:02 »

the major problem is going to be the undocumented stuff on the jetengine part of MS Access as its not an acutal real db but a front end..

might I suggest MSDN..MS Access does not use JDBC and doesn't use standard odbc either..


Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #5 - Posted 2004-03-23 20:58:33 »

A M$ product using proprietry components?
you do suprise me ^_^
Ah well, im glad I was wrong - atleast it got the Thread going Wink

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline puf

Senior Newbie




Java games rock!


« Reply #6 - Posted 2004-03-24 04:48:49 »

The first question you need to ask yourself is if you really want the database to reside on the j2me device.

Keep in mind that relational databases tend to grow large pretty fast. And since most j2me devices have not much memory, it might not be an option. Of course this really depends on you intended target device(s) and usage scenario.

If you really need the database on the device, also keep in mind that you need to have a library that allows you to access the MDB (access database) on the device. On a j2se or j2ee system you would use JDBC for this, but that's probably not an option for a j2me device due to the size of such libraries.

Does this help? If so, then please answer the question whether you really need the database to be physically on the j2me device.
Offline beyonder

Junior Newbie




Java games rock!


« Reply #7 - Posted 2004-03-24 06:49:30 »

sorry i would like to clear all doubts here i know that the ms access db cannot be on the midlet due to low memory but i can call my midlet to access a db through JSP right? i know how to access a db through JSP but what i don't know is the midlet part how do i call my JSP page in J2ME? it's call data.jsp  Grin
Offline shmoove

Junior Member




Doh!


« Reply #8 - Posted 2004-03-24 08:23:49 »

The MIDlet accesses the jsp page by using the General Connection Framework (javax.microedition.io.*). More specifically, you'll probably use the HttpConnection class.
Here's a tutorial about that.
Once you have the connection and you have received the response, it's up to you what to do with the data. The jsp page can produce the data in an XML format and you could use a library like kXML to parse the data. But that does have some overhead, so you might want to considering sending the data in a simpler format. For example, you could just send the data as a comma-separated string, and then it would be really easy to parse.
The point is, there are no built-in solutions. You need to either roll your own, or get some third-party libraries.

shmoove
Offline beyonder

Junior Newbie




Java games rock!


« Reply #9 - Posted 2004-03-25 09:56:21 »

yeah hi i know there is a xml parser ..but how do i use it? know any good links?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline shmoove

Junior Member




Doh!


« Reply #10 - Posted 2004-03-25 10:41:00 »

http://developers.sun.com/techtopics/mobility/midp/articles/parsingxml/

But unless the data you receive needs to be really dynamic, I don't think the overhead is worth it.
For simple applications I would output the data in a simple format like a comma-separated string and parse it manually.

shmoove
Offline wooD

Senior Newbie




J2ME Developer


« Reply #11 - Posted 2004-03-25 14:30:49 »

Quote
But unless the data you receive needs to be really dynamic, I don't think the overhead is worth it.


I agree that doing XML parsing on a real phone could cause some major memory headaches. All the database stuff I've done to phones has been through a web app, but I tend to pass stuff back to the app in some sort of delimited format.  You will not get Access to run on the phone.  Even if you did get some db to run, memory is so limited that some sort of delimited format would be a better option, although still not recommended.

In many cases, I use a sort of chunked encoding with two bytes as the delimiter.  'me' = mission element, then some well defined data after it, then 'mp' for the map, then 'en' for end of data.

On the j2me client I lock down a two byte array so I'm doing as little dynamic memory usage as possible.

This is a code snipet that came from an app that had to connect to an existing php app.  I was able to add to the php to respond differently to the j2me app.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
  // these are shared in the headers of the various network calls
 private static final String ifModifiedKey = "IF-Modified-Since";
  private static final String ifModifiedData = "20 Jan 2001 16:19:14 GMT";
  private static final String userAgentKey = "User-Agent";
  private static final String userAgentData = "Profile/MIDP-1.0 Configuration/CLDC-1.0";
  private static final String contentLangKey = "Content-Language";
  private static final String contentLangData = "en-US";
  private static final String contentTypeKey = "Content-Type";
  private static final String contentTypeUrlData = "application/x-www-form-urlencoded";
  private static final String contentTypeFormData = "multipart/form-data; boundary=---1234";
  private static final byte[] boundaryBytes = "-----1234".getBytes();


    String url = "http://www.yourhost.com/yourapp/login.php";
    try
      {
      c = (HttpConnection)Connector.open(url);
               
      // Set the request method and headers
     c.setRequestMethod(HttpConnection.POST);
      c.setRequestProperty(ifModifiedKey, ifModifiedData);
      c.setRequestProperty(userAgentKey,userAgentData);
      c.setRequestProperty(contentLangKey, contentLangData);
      c.setRequestProperty(contentTypeKey,contentTypeUrlData);

      // Getting the output stream may flush the headers
     os = c.openOutputStream();
      os.write("namefield=".getBytes());
      usernameBytes = tfLoginName.getString().getBytes();
      os.write(usernameBytes);
      os.write("&passfield=".getBytes());
      os.write(tfLoginPass.getString().getBytes());
      os.write("&login=Log+In\n".getBytes());


Reading the response method looked like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
    boolean done=false;   
    while (!done)
      {
      // read two character codes
     opcode[0] = (byte) is.read();
      if (opcode[0]==-1)
        {
        return amtread;
        }
      //System.out.println("op0="+((char)opcode[0]));
     amtread++;

      opcode[1] = (byte) is.read();
      if (opcode[1]==-1)
        {
        //System.out.println("Error reading second opcode");
       return -1;
        }
      amtread++;
      //System.out.println("op1="+((char)opcode[1]));
     // start checking opcodes
     if ((opcode[0]=='m') && (opcode[1]=='e'))
        {
         // do something here
       }


This is not meant to be pretty, it was meant to save as much dynamic memory allocation as possible.  I just don't trust the j2me garbage collectors.

Also, the back end for this is mysql, I wouldn't use Access for a web app unless I knew it was for a limited audience or there was some serious customer requirement and I couldn't talk them out of it.

Hopefully that helps a little.

Wood

Offline edliu

Junior Newbie




Java games rock!


« Reply #12 - Posted 2004-04-11 12:25:56 »

Grin

USe this liobrary  www.j2ASPX.com/lib

it actually enables J2ME to interface with ASPX.  It is simple and easy to use.

With about 15 lines of codes, it can actually retrice and send commands to databases controlled by ASPX.

Regards
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (14 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!