Results 1 to 2 of 2

Thread: Parse J2ME PHP

  1. #1
    baby_cweetie is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Red face Parse J2ME PHP

    Hello all,
    today i've homework from my lecturer about parse J2ME
    i'm using j2me and php
    and that my j2me integrated with php,,
    i mean like this,,
    first, i create database in mysql,,
    Parse J2ME PHP-database.jpg

    then after that i create connection between php and mysql,,
    this is my connection between php and mysql
    Java Code:
    <?php
    $link_id = mysql_connect("localhost", "root", "");
    if(!mysql_select_db("mobile", $link_id)) die ("error");
    $ID = $_GET['ID'];
    $result = mysql_query("Select * FROM student where ID = '$ID'", $link_id);
    $baris = mysql_fetch_array($result);
    echo $baris['name']; 
    
    ?>
    after i finish create connection then i make a program in j2me then create connection between j2me and php
    this is my connection
    Java Code:
           public String koneksi(String myurl)
        {
    
          HttpConnection connection = null;
          InputStream inputstream = null;
          try
          {
            connection = (HttpConnection) Connector.open(myurl);
            //HTTP Request
            connection.setRequestMethod(HttpConnection.GET);
            connection.setRequestProperty("Content-Type","//text plain");
            connection.setRequestProperty("Connection", "close");
            // HTTP Response
            System.out.println("Status Line Code: " + connection.getResponseCode());
            System.out.println("Status Line Message: " + connection.getResponseMessage());
            if (connection.getResponseCode() == HttpConnection.HTTP_OK)
            {
              System.out.println(
                connection.getHeaderField(0)+ " " + connection.getHeaderFieldKey(0));
              System.out.println(
               "Header Field Date: " + connection.getHeaderField("date"));
              //String str;
              inputstream = connection.openInputStream();
              int length = (int) connection.getLength();
              if (length != -1)
              {
                byte incomingData[] = new byte[length];
                inputstream.read(incomingData);
                str = new String(incomingData);
              }
              else
              {
                ByteArrayOutputStream bytestream =
                      new ByteArrayOutputStream();
                int ch;
                while ((ch = inputstream.read()) != -1)
                {
                  bytestream.write(ch);
                }
                str = new String(bytestream.toByteArray());
                bytestream.close();
              }
              //System.out.println(str);
             // return str;
            }
          }
          catch(IOException error)
          {
           System.out.println("Caught IOException: " + error.toString());
          }
          finally
          {
            if (inputstream!= null)
            {
              try
              {
                inputstream.close();
              }
              catch( Exception error)
              {
                 /*log error*/
              }
            }
            if (connection != null)
            {
              try
              {
                 connection.close();
              }
              catch( Exception error)
              {
                 /*log error*/
              }
            }
          } //finally
            return str;
        }
    and this is my form
    Form Input
    Parse J2ME PHP-1.jpg
    Form Output
    Parse J2ME PHP-2.jpg
    When i enter ID then the result will show in textfield(form output) which the result is from record in mysql database
    My lecturer told about parse J2ME
    That parsing will find unique character like "#"
    So my record from mysql databse will be like "ID#Name#Class"
    and after that j2me will separate that record like
    textfield1 is ID
    textfield2 is Name
    textfield3 is Class
    please help me

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Parse J2ME PHP

    See the second paragraph of the Forum Rules.

    Closing this thread and it will be removed later.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Sax Parse xml
    By siddheshwar in forum XML
    Replies: 1
    Last Post: 06-25-2011, 08:12 PM
  2. How to parse this value
    By Ajitha in forum New To Java
    Replies: 2
    Last Post: 06-03-2010, 07:26 AM
  3. using parse
    By mustachMan in forum New To Java
    Replies: 2
    Last Post: 01-15-2010, 01:32 AM
  4. Replies: 0
    Last Post: 04-22-2009, 01:30 PM
  5. SAX Parse
    By bluefloyd8 in forum New To Java
    Replies: 1
    Last Post: 01-25-2008, 03:57 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •