Results 1 to 3 of 3
- 06-19-2012, 06:58 PM #1
Member
- Join Date
- Jun 2012
- Posts
- 2
- Rep Power
- 0
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,,

then after that i create connection between php and mysql,,
this is my connection between php and mysql
after i finish create connection then i make a program in j2me then create connection between j2me and phpJava 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']; ?>
this is my connection
and this is my formJava 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; }
Form Input

Form Output

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 meLast edited by baby_cweetie; 06-20-2012 at 12:51 PM.
- 06-20-2012, 12:08 AM #2
Re: How to display result in textfield?
Moved from New to Java
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 06-20-2012, 07:12 PM #3
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.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Using jTable to display query result
By zenith666 in forum New To JavaReplies: 2Last Post: 01-13-2012, 02:29 AM -
display result from rs232
By sisavi in forum New To JavaReplies: 0Last Post: 12-05-2011, 12:52 PM -
How to display integers in textField
By mDennis10 in forum New To JavaReplies: 11Last Post: 08-12-2011, 02:14 AM -
Struts 2 error : No result defined for action / result
By sameerk in forum Web FrameworksReplies: 1Last Post: 05-17-2011, 10:15 AM -
Can someone please explain to me the proper way to display the result of a SQL query
By Turk80 in forum New To JavaReplies: 1Last Post: 04-11-2011, 01:39 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks