Android Login activity with MySQL database connection

Here I'm going to create a simple Android log in application  which can post data to a java web service and read data from MySQL database using a java web service to authenticate the user. Tested on Android 2.2.
(In latest versions of Android you cannot access the web in same way mentioned here. if you are planning implement web access for version 3.0 or higher than that follow one of below methods

Quick demo :



The complete project has three main components

1. A MySQL database which holds user name and password. 
2. A java web service deployed on Tomcat server.
3.Android application to access the database through the java web service to verify the user. 

1. Databse
First we have to create a database and table to store user information. To create the database I used MySQL command line client. (If you like you can use phpmyadmin it is easier)
In order to create the database, a table and to populate the database run following queries.
a. Create the database
?
1
CREATE DATABSE androidlogin;
b. Select the database
?
1
USE androidlogin;
c. Create a table
?
1
2
3
CREATE TABLE user(
username VARCHAR(20) NOT NULL,
password VARCHAR(20) NOT NULL);
d.Populate the database
?
1
2
INSERT INTO user(username,password)
VALUES('admin','123');

2. Java webservice
Create the java web service in Eclipse. Follow the steps mentioned hereAdditionally you have to import JDBC connector to the web service project.   
Here is the content for java web service.
?
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
34
35
36
37
38
39
40
41
42
package com.userlogin.ws;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Login {
 public String authentication(String userName,String password){
   
  String retrievedUserName = "";
  String retrievedPassword = "";
  String status = "";
  try{
    
   Class.forName("com.mysql.jdbc.Driver");
   Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/androidlogin","root","chathura");
   PreparedStatement statement =  con.prepareStatement("SELECT * FROM user WHERE username = '"+userName+"'");
   ResultSet result = statement.executeQuery();
    
   while(result.next()){
    retrievedUserName = result.getString("username");
    retrievedPassword = result.getString("password");
    }
    
   if(retrievedUserName.equals(userName)&&retrievedPassword.equals(password)){
    status = "Success!";
   }
    
   else{
    status = "Login fail!!!";
   }
    
  }
  catch(Exception e){
   e.printStackTrace();
  }
  return status;
  
 }
}

> For more details read my first post.
> "root" and "chathura" in line 17 are user and the password of the database. You need to change those according to your settings.

3. Android application.
a. Code for main activity
?
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.androidlogin.ws;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class AndroidLoginExampleActivity extends Activity {
 private final String NAMESPACE = "http://ws.userlogin.com";
    private final String SOAP_ACTION = "http://ws.userlogin.com/authentication";
    private final String METHOD_NAME = "authentication";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button login = (Button) findViewById(R.id.btn_login);
        login.setOnClickListener(new View.OnClickListener() {
    
   public void onClick(View arg0) {
    loginAction();
     
   }
  });
    }
     
    private void loginAction(){
     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
      
        EditText userName = (EditText) findViewById(R.id.tf_userName);
        String user_Name = userName.getText().toString();
        EditText userPassword = (EditText) findViewById(R.id.tf_password);
        String user_Password = userPassword.getText().toString();
         
      //Pass value for userName variable of the web service
        PropertyInfo unameProp =new PropertyInfo();
        unameProp.setName("userName");//Define the variable name in the web service method
        unameProp.setValue(user_Name);//set value for userName variable
        unameProp.setType(String.class);//Define the type of the variable
        request.addProperty(unameProp);//Pass properties to the variable
        
      //Pass value for Password variable of the web service
        PropertyInfo passwordProp =new PropertyInfo();
        passwordProp.setName("password");
        passwordProp.setValue(user_Password);
        passwordProp.setType(String.class);
        request.addProperty(passwordProp);
           
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
         
        try{
            androidHttpTransport.call(SOAP_ACTION, envelope);
               SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
                 
               TextView result = (TextView) findViewById(R.id.tv_status);
               result.setText(response.toString());
           
        }
        catch(Exception e){
           
        }
       }
     
}

> You need to import ksoap2 library for the Android project.
> You cannot access the URL in above code because the web service is deployed in Tomcat server installed in my computer not in a cloud server therefore you have to replace that with an URL for your own web service.  
>  For more details check these posts.
 1. Post 1
 2. Post 2

b. Content of main.xml
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<absolutelayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
    <edittext android:id="@+id/tf_userName" android:layout_height="wrap_content" android:layout_width="194dp" android:layout_x="106dp" android:layout_y="80dp">
        <requestfocus>
    </requestfocus></edittext>
    <textview android:id="@+id/textView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_x="23dp" android:layout_y="93dp" android:text="User name">
    <edittext android:id="@+id/tf_password" android:inputtype="textPassword" android:layout_height="wrap_content" android:layout_width="189dp" android:layout_x="108dp" android:layout_y="161dp">
    <textview android:id="@+id/TextView01" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_x="23dp" android:layout_y="176dp" android:text="Password">
    <button android:id="@+id/btn_login" android:layout_height="wrap_content" android:layout_width="106dp" android:layout_x="175dp" android:layout_y="273dp" android:text="Login">
    <textview android:id="@+id/tv_status" android:layout_height="38dp" android:layout_width="151dp" android:layout_x="26dp" android:layout_y="234dp" android:textappearance="?android:attr/textAppearanceMedium">
</textview></button></textview></edittext></textview></absolutelayout>

c. You need to add internet permission to the project
Manifest.xml
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<manifest android:versioncode="1" android:versionname="1.0" package="com.androidlogin.ws" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-sdk android:minsdkversion="8">
    <uses-permission android:name="android.permission.INTERNET">
    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
        <activity android:label="@string/app_name" android:name=".AndroidLoginExampleActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN">
                <category android:name="android.intent.category.LAUNCHER">
            </category></action></intent-filter>
        </activity>
    </application>
</uses-permission></uses-sdk></manifest>

You can download Android project here
(After downloading the project first remove imported ksoap2 library from the project and re import ksoap2 from your hard disk ) 

8 TEMPAT WAJIB BILA KUNJUNGI PULAU PINANG


Assalamualaikum dan salam sejahtera

Sudah lama GMMS menyepi, sekejap ada sekejap takde. Sibuk dengan hal dunia membuatkan blog ini sedikit terabai tapi takpela janji dia masih bernyawa. Okey, apabila melihat dan membaca tajuk 8 TEMPAT WAJIB BILA KUNJUNGI PULAU PINANG kat atas dalam hati, sudah tentu kalian akan imbas kembali memori suasana percutian ketika berada di Pulau Pinang suatu tika dulu. Sememangnya ia menyeronokkan dan mengujakan!

Tanpa membazirkan dakwat elektronik ini, aku senaraikan 8 TEMPAT WAJIB BILA KUNJUNGI PULAU PINANG. Semoga kalian mengiyakan dan menggangguk serta bersetuju dengan tempat-tempat tersebut.


1.Jambatan Pulau Pinang




Jambatan ini adalah nadi kepada Pulau Pinang. Sinilah segala pintu keindahan Pulau Pinang akan bermula dari sini. Jambatan yang pernah disenaraikan antara yang terpanjang di dunia--13.5km, sememangnya menawarkan satu lokasi yang mengujakan. Untuk mengetahui apakah keistimewaan tersebut, silalah merakam foto jambatan ini ketika waktu senja atau awal pagi. SubhanaAllah pasti akan terucap di bibir kalian.

Cara untuk ke sana: Sila naiki Bas Rapid Pulau Pinang No. 704 dari Komtar


2.Bukit Bendera




Bukit Bendera yang terletak 380 meter di atas paras laut telah mewujudkan stesen keretapi yang pertama di kawasan bukit. Stesen keretapi ini adalah klasik kerana telah beroperasi sejak tahun 1922 lagi. Kalian boleh naik ke puncak Bukit Bendera ini dengan menggunakan keretapi itu atau merentas kawasan hutan secara berkumpulan. Atas puncak bukit ini, kalian dapat melihat keindahan bandar Pulau Pinang. Bayaran masuk ke bukit Bendera ini dikatakan berharga RM4 untuk dewasa dan RM2 untuk kanak-kanak. Jadi ini adalah satu pengalaman percutian yang menarik untuk dilakukan bersama seisi keluarga. 

Cara untuk ke sana: Dari Jeti, Komtar, dan Lebuh Chulia, sila naiki bas Rapid Pulau Pinang No. U204, bas ini akan membawa anda terus ke Bukit Bendera. Anda juga boleh mengambil teksi dengan tambang sebanyak RM20 sehala.


3. Taman Rama-rama Pulau Pinang di Teluk Bahang




Ketahuilah yang taman ini diiktiraf sebagai Santuari Rama-rama dan Serangga Tropikal yang pertama di dunia. Barang world class la katakan. Taman ini mengandungi ribuan rama-rama yang mempunyai 50 spesies yang berbeza. Tempat ini juga menempatkan kala jengking, katak dan pelbagai jenis serangga. Bila sudah diklafikasikan sebagai taman rama-rama, sudah semestinya tempat penetasan rama-rama, makmal, ruang pameran dan kedai cenderamata diwujudkan. Bayaran masuk dikenakan adalah RM5 untuk dewasa dan RM2 untuk kanak-kanak. Bagi yang geli dengan rama-rama, face your fear. Rama-rama sungguh friendly dan mendamaikan hati bila ia singgah di tapak tangan kalian.

Cara untuk ke sana: Sila naiki Bas Rapid Pulau Pinang No. 101. 102. atau 501.


4.Tokong Kek Lok Si di Ayer Hitam




Tokong ini adalah tokong Buddha yang paling cantik di Asia Tenggara. Lokasi tokong ini di Ayer Hitam. Tokong ini juga dikenali sebagai Pagoda of Ten Thousand Buddhas. 20 tahun untuk diambil bagi membina dan menyiapkan tokong ini. Dalam tokong ini ada taman-taman yang indah, kolam kura-kura, skulptur unik serta makam. Free untuk melawat tokong ini.
*skulptur-seni patung


Cara untuk ke sana: Bergantung kepada di mana anda datang, anda boleh menaiki bas Rapid Pulau Pinang No. U201, U203, U204, U206, T306, dan U502. Teksi dari George Town adalah kira-kira RM20. Jika memandu, sila merujuk kepada papan tanda ke Air Itam. Setelah sampai ke Air Itam, anda boleh melihat papan tanda yang menunjukkan arah ke kuil.



5.Fort Cornwallis di Lebuh Light




Kubu ini dibina di kawasan pendaratan Francis Light pada tahun 1786. Jadi ini adalah peninggalan sejarah yang masih utuh. Kini, ia berfungsi sebagai tempat teater, galeri bersejarah dan kedai-kedai menjual hasil kraftangan. Ia juga menempatkan meriam bersejarah milik Belanda, yang dihadiahkan kepada Sultan Johor, yang sebelum itu pernah dicuri oleh penjajah Portugis. Kawasan ini boleh dilawati dari jam 8.30 pagi hingga 7.00 malam. Bayaran masuk adalah RM1 untuk semua usia. Untuk mengenali sesebuah negera, lawatla tempat-tempat bersejarah kerna disitula segala maklumat dan fakta kelahiran negara tersebut dapat diketahui.

Cara untuk ke sana: Anda boleh ke sana dengan menaiki Bas Rapid Pulau Pinang No. 103, 204, 502, atau, 10.


6. Masjid Terapung di Tanjung Bunga




Masjid yang bernilai RM 15 juta ini menampilkan seni bina yang unik hasil gabungan pengaruh rekaan tempatan dan Timur Tengah.  Masjid ini juga dikenali sebagai Mutiara Timur, ini kerana rupa bentuk bentuk masjid yang kelihatan seperti mutiara. Masjid ini mampu menampung sekitar 1500 jemaah dalam satu masa. Masjid ini terletak di tepi pantai menghala ke Batu Ferringhi. Pengalaman penulis yang ingin lakukan dan kumpulkan ialah mengerjakan solat jumaat di setiap negeri yang mempunyai masjid yang menjadi identiti sesebuah negeri.

Cara untuk ke sana: Naiki Bas Rapid Pulau Pinang No. 101 atau 102.


7. Taman Botanikal Pulau Pinang




Taman yang seluas 30 hektar ini menempatkan pelbagai tumbuhan tropika yang terdapat di Pulau Pinang. Malah ada air terjun di kawasan tersebut. Jadi ketenangan dan kedamaian menjadi tarikan utama taman ini untuk kalian carikan sesuatu yang diberi nama iaitu semulajadi. Sejarah taman ini mengatakan penjajah British telah membuka taman tersebut pada tahun 1884. Taman ini dibuka pada 7 pagi hingga 7 malam dan menariknya taman ini FREE untuk dimasuki. Jadi jikalau ingin merawat mata setelah banyak menggunakan ia untuk urusan kerja atau berdepan dengan komputer untuk tempoh yang lama, sinila tempatnya.


Cara untuk ke sana: Anda boleh berjalan ke Taman Botanikal dari Pengkalan Weld, jika suka berjalan. Lintasi Pengkalan Weld melalui jambatan pejalan kaki, belok kiri dan jalan sehingga sampai ke simpang Gat Lebuh Chulia. Belok kanan dan berjalan sehingga anda tiba di Taman Botanikal. Jika tidak, cuma naiki Bas Rapid Pulau Pinang No.10 dari Pengkalan Weld atau Komtar ke Taman Botanikal.



8.Muzium Islam Pulau Pinang (Rumah Agam Syed Al-Attas) di Lebuh Armenia.




Syed Al-Attas adalah insan yang membina muzium ini pada tahun 1860. Beliau adalah seorang pedagang lada dari Acheh. Reka bentuk bangunan ini menampilkan pengaruh seni bina India, Eropah dan Arab. Muzium ini mempamerkan sejarah dan perkembangan Islam di Pulau Pinang dan negeri-negeri lain di Malaysia sejak permulaan kedatangan agama Islam sehingga sekarang. Muzium ini juga dikatakan pernah menjadi pusat penyimpanan senjata ketika menentang penjajahan Jepun di Tanah Melayu satu ketika dahulu. Muzium ini dibuka pada setiap hari kecuali hari Selasa, dari jam 9.30 pagi sehingga 6.00 petang. Jangan tanya kenapa hari Selasa ditutup. Bayaran masuk dikenakan RM3 untuk dewasa dan RM 1 untuk kanak-kanak.

Cara untuk ke sana: Muzium Islam Pulau Pinang dapat dilawati dengan menaiki Bas Rapid Pulau Pinang No. 10, 301, 302, 307, 401, dan U502, turun di Lebuh Carnavon. Jalan sepanjang Lebuh Carnavon ke simpang Lebuh Acheh. Dalam jarak yang dekat, ke kiri, adalah Lebuh Armenian. Muzium Islam Pulau Pinang adalah di sebelah kiri simpang.

Penulis: Sebenarnya banyak lagi tempat-tempat menarik di Pulau Pinang ini seperti Masjid Kapitan Keling, Kilang Batik Pulau Pinang, Tokong Ular, Akuarium Perikanan Pulau Pinang, Muzium Mainan dan macam-macam lagila.  Hang, demo, ko, mung atau siapa-siapala jangan dok ralit gak gi ngular tempat oversea, negara kita sendiri world class bab pelancongan ni. Majulah industri pelancongan negara kita.

Download Young Justice: Legacy for PC


In Play Young Justice: Legacy fans can play the main story narrative between seasons 1 and 2 of the animated television series it could be. The co-authors of the original version of the animated series, namely Greg Weisman and Brandon Vietti has occurred. Play along with fan favorite characters and heroes and villains have this animation cartoon series Young Justice seekers are present in the game. The game has a multiplayer mode is online and offline gamers to experience a fascinating game will link together.
Young Justice: Legacy PC-RELOADED

Young Justice Legacy pc cover download Young Justice: Legacy for PC

Minimum System Requirements:
OS: Windows XP Processor: 2Ghz Dual Core Memory: 2 GB RAM Graphics: NVidia GeForce 6800 or ATI Radeon X1950 or better with 256MB VRAM DirectX: Version 9.0c Network: Internet broadband connection Hard Drive: 3 GB available space 






Pictures from the game:
Young Justice Legacy screenshots 01 small game download Young Justice: Legacy for PC Young Justice Legacy screenshots 02 small game download Young Justice: Legacy for PC
Young Justice Legacy screenshots 03 small game download Young Justice: Legacy for PC Young Justice Legacy screenshots 04 small game download Young Justice: Legacy for PC

source Download Young Justice: Legacy for PC Description Installation: After download and extract the part, note that your antivirus is disabled. We have achieved ISO file with Daemon Tools software to install, run and play. After installing the game, all the files in the Crack folder to the game installation replace. Zip install method and tested and are safe. The team hopes Downloads Enjoy this beautiful game.

caution Download Young Justice: Legacy for PCNote: From now on, the volume of compressed files are over 100 MB in 5% recovery. This feature makes the problem Extract the files completely to zero. To use this feature, you have to download the file and Extract encounter problems, software Winrar and run to see where they've downloaded the zip file, and select Options All Parts Repair the Press the upper part of the software is available. Then choose a suitable place to store them. Upon completion of the work, and go to where you chose to store the extracted files to pay.

download Download Young Justice: Legacy for PC Download as Part of 1GB:
Download Part 1:     Direct Link
Download Part 2:     Direct Link
Download Part 3:      Direct Link

PowerDirector 11

PowerDirector is a powerful software application for creating and editing home videos is simple.This software is equipped with the new technology, the fastest and best method for providing video editing. There are over 100 effects and over 300 effects software free DirectorZone.com the software will look great. The software has revolutionized video editing. The software analyzes video footage of identifying faces, zoom, scroll, and the image is perfect and can modify the vibration, light and sound shows on the agenda. This software will take HD quality video editing software in the format of the HD and 4K Video Support for this unique software. This software is powerful and can design and manufacture all designs as well as Title Designer and do PiP Designer and menu design. There is also a slideshow effects of their actions on the videos as well as other features. Minor features such as cut and rotate and are very small considering the powerful software. Take advantage of the videos have a green back, and they may be edited. Part of the software embedded in the task TrueTheater video noise removal, color correction, eliminating vibration and increase the video quality is. Support for Dolby Digital audio, video and 4K Video HD and FULL HD 3D videos as well as complete software from Cyberlink introduced. To output all popular formats are supported by a software multimedia world. The speed of the CPU and graphics card compatibility and improved software will occupy a smaller percentage. This software is very powerful and it is better to know all of its features to its manufacturer's website to see Cyberlink.com.

PowerDirector Ultra v11 powerful video editing software CyberLink PowerDirector Ultra 11.0.0.3230




Powerful video editing software CyberLink PowerDirector Ultra 11.0.0.3230 passwordFile encryption:  Www.downloadha.com