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

    Default Parse J2ME

    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,,
    How to display result in textfield?-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
    How to display result in textfield?-1.jpg
    Form Output
    How to display result in textfield?-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
    Last edited by baby_cweetie; 06-20-2012 at 12:51 PM.

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

    Default Re: How to display result in textfield?

    Moved from New to Java

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

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

    Default Re: How to display result in textfield?

    See the second paragraph of the Forum Rules.

    Your second thread has been closed and will be removed later.

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

Similar Threads

  1. Using jTable to display query result
    By zenith666 in forum New To Java
    Replies: 2
    Last Post: 01-13-2012, 02:29 AM
  2. display result from rs232
    By sisavi in forum New To Java
    Replies: 0
    Last Post: 12-05-2011, 12:52 PM
  3. How to display integers in textField
    By mDennis10 in forum New To Java
    Replies: 11
    Last Post: 08-12-2011, 02:14 AM
  4. Struts 2 error : No result defined for action / result
    By sameerk in forum Web Frameworks
    Replies: 1
    Last Post: 05-17-2011, 10:15 AM
  5. Replies: 1
    Last Post: 04-11-2011, 01:39 AM

Posting Permissions

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