Preview:
DESCRIPTION
fafarafafafafa
Citation preview
Interkoneksi client server (PHP MySQL)
To be discussed in
Terdapat 3 format ChoiceGroup :
– ChoiceGroup(String label, int choiceType, String[]
stringElements, Image[] imageElements)
Membuat obyek ChoiceGroup, menentukan title dan tipe serta array
dari string dan gambar untuk nilai awal.
Untuk passing parameter dari pilihan user gunakan
getSelectedIndex(), getString(int elementNum) and isSelected(int
elementNum).
J2ME provides networking features to the mobile devices.
It is possible to get up-to-the-minute stock quotes or updated
currency exchange rates on a mobile phone.
The javax.microedition.io classes and interfaces handle the
networking capability of MIDP.
The java.io package provides input/output (I/O) capability to
MIDP.
– Low-level IP networking
– HTTP networking
– Secure networking
This category involves socket, datagram, serial port, and file I/O
communication.
Socket-based communication conforms to the connection-oriented
TCP/IP protocol.
Datagram-based communication conforms to the connectionless UDP/IP
protocol.
e.g. URI for a datagram connection for sending to a server on a
certain port:
– datagram://123.456.789.12:1234
HTTP networking
The communication between a mobile device and a Web server is based
on HTTP (Hypertext Transfer Protocol).
HTTP is a connection-oriented request-response protocol.
The Connection Framework
J2ME networking was designed to address the diverse needs of a wide
range of mobile devices.
At the same time, the networking system must be device
specific.
To meet these challenges, it introduces the concept of a generic
connection framework.
Generic connection framework is to define the general aspects of
the networking and file I/O in the form of Java interfaces for a
broad range of handheld devices
URL Handling in J2ME
URL handling in J2ME involves opening a connection to the Web
server from the mobile device and handling data I/O between the
two.
The process happens in the following stages:
– Setup
– Connected
– Closed
J2ME defines the javax.microedition.io.Connector class to
create all the connection objects.
URL Handling in J2ME
The string parameter to the Connector.open() method is a valid
URL.
The URL string varies depending on the communication protocol, as
Examples 1 through 5 below demonstrate.
Example 1. Invoking HTTP-based communication Connection conn
=
Connector.open("http://www.yahoo.com");
Connector.open("socket://localhost:9000");
Connector.open("datagram://:9000");
Connector.open("comm:0;baudrate=9000");
Connector.open("file://myfile.dat");
URL Handling in J2ME
The Connector.open() method also accepts the access mode (values
READ, WRITE, and READ_WRITE), and a flag to indicate that the
caller wants a timeout notification.
– static Connection open(String name, int mode)
– static Connection open(String name, int mode, boolean
timeouts)
A DataInputStream/DataOutputStream lets an application
read/write primitive Java data types.
server
server
Passing Parameters to Server
Passing Parameters to Server
e.g. Login in case.
A server must authenticate a client using the client’s user
ID and password.
The client sends the user ID and password along with the HTTP
request.
Two techniques are used to send data to the server: GET or POST
request methods.
Passing Parameters to Server
Data sent to a server must be in a pair value set: – field
name – the value associated with the field.
The field name and value must be separated by an equal sign
(=).
The pair value sets are separated from the URL by a question mark
(?).
Each pair value set is separated from other pair value sets by an
ampersand (&).
The space character is converted to a plus (+) sign.
For example, the following request sends two parameters: pOne="one
bit" and pTwo="two"
http://127.0.0.1/modul13/simple.php?p=one+bit&pTwo =two
server
server
Interaksi dengan Database (Review) Dalam pembuatan aplikasi
berbasis Database –
WAP, beberapa perintah di Database baik DML dan DDL bisa digunakan
dikarenakan aksesnya masih berbasis PHP.
Beberapa tahapan dalam interkoneksi dengan Database :
Membuka koneksi ke server MySQL
$conn = mysql_connect (”host”,”username”,”password”);
Memilih database
Buat database KAMPUS, dengan tabel Mahasiswa yang memiliki field
sebagai berikut, dengan NRP sebagai Primary Key :
pemakaian PDAM :
Pemakaian : 20 [TextField]
a. Blok Diagram Sistem