Friday, 2 August 2013

Manually Install APK file into Android Emulator

Hai guys following steps will help you to install APK file into Android Emulator

Step 1:
Start Emulator from ADT

Step 2:
Paste your apk file into platform tools folder of your downloaded SDK.

Step 3:
open Command Prompt and Move to Platform tools folder location.

Step 4:
type following lines in Command Prompt

adb install [apk file name]

for example

adb install helloworld.apk

Now you have successfully installed your apk file into Emulator..


Thanks for Your Visit

Regards with..
Parthasarathy

Get Phone Number From Android

Hai guys after big gap again i am going to start my blogging..
Really i faced big problem with Phone number picking method in android. finally i came to its not possible.
because most of the network service provider will not store phone number in the SIM card.

if they stored number in Sim card  the following code will work..

TelephonyManager tm=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
 mynumber=String.valueOf(tm.getLine1Number());



If you need any of the unique number from Sim means you may use Sim serial number..
The following code will guide you get Sim Serial Number

TelephonyManager tm=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String sim=String.valueOf(tm.getSimSerialNumber());

Another Method to retrieve phone number is we can get Phone number from Message Sent Items..
But its also not sure to get correct number..



Friday, 8 February 2013

Get Selected JRadioButton From ButtonGroup

Hai friends now i am going to share how we can get selected JRadioButton from ButtonGroup..

























GettingRadioButtonValueTwo.java


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Enumeration;

import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;


public class GettingRadioButtonValueTwo implements ActionListener {
 JRadioButton rb1 =new JRadioButton("Sarathi");
 JRadioButton rb2=new JRadioButton("Bishop");
 JFrame f=new JFrame("Radio Button Example");
 JPanel p=new JPanel();
 JLabel l=new JLabel("Answer");
 JButton b=new JButton("Submit");
 ButtonGroup bg=new ButtonGroup();
 
 public void init()
 {
  bg.add(rb1);
  bg.add(rb2);
  p.add(rb1);
  p.add(rb2);
  p.add(b);
  p.add(l);
  f.add(p);
  f.setSize(500, 500);
  f.setVisible(true);
  b.addActionListener(this);
 }
 public static void main(String args[])
 {
  GettingRadioButtonValueTwo gr=new GettingRadioButtonValueTwo();
  gr.init();
 }
 @Override
 public void actionPerformed(ActionEvent arg0) {
  // TODO Auto-generated method stub
  String ss="";
  Enumeration e=bg.getElements();
  while(e.hasMoreElements())
  {
   JRadioButton r=(JRadioButton)e.nextElement();
   if(r.isSelected())
   {
    ss=r.getText();
   }
  }
  l.setText(ss);
  
 }

  
}



Thanks for Visiting
 -- 
Regards with

R. Partha Sarathy

Sunday, 27 January 2013

Import and Export SQLite Database file into Android Eclipse using SQLite Browser

Hai Friends today i am going to explain how to import and export SQLite Database file into Eclipse


         First of all we have to locate our database file...
         Here you can refer how to locate database file in Eclipse (Refer Here)
         (Note:  First Run Your Program then only you can Find your Database file)


For Export:

Step 1:
Select our Database File and Click "Pull a file from the device " button (top left corner)

 Step 2:
      Browse Location and Press Save button



Now your database file Successfully Exported.
You can see data with use of SQLite Browser


For Import:

Step 1:
Select database folder and Click "Push a file onto the device" button(top Left Corner)


Step 2:
 Browse File Location and Press Open Button


Step 3:
Now Your file has successfully imported...


         
         Thanks For Visiting...





How to Create Simple table in SQLite Browser

Hai friends now i going to explain how to create table in SQLite Browser,

First think we need to download SQLite Browser

Step 1:
Download SQLite Browser (click here)

Step 2:

Install SQLite Browser into our Computer

Step 3:
Select File->New->Database


Step 4:
Give name for Database and press save button


Step 5:
Give table name for database
and add column name and type...




Step 6:
Press Create button..
Now your table has created..



Step7:
Select Browse Data Tab and choose table name


Step8:
Press New Record button and enter values..


Thanks for Visiting...


Android with SQLite Database Connectivity in Simple Way

Hai Friends today i am going to share about how we can connect android with SQLite Database in Simple way for Efficient Purpose..
Try this program on Android Ginger bread Version.

Snapshots:










Copy and Paste following code into Eclipse and Run the Program.

LoginSecurity.java
package login.log;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class LoginSecurity {
 String DbName="NewLogin";
 String DbTable="logi";
 int DbVersion=1;
 String Key_Name="Name";
 String Key_Pass="Password";
 String CreateTable="create table logi(Name text not null, Password text not null);";
 sqlitehelper shelp;
 SQLiteDatabase sbase;
 Context con;
 public LoginSecurity(Context c)
 {
  con=c;
 }
 public LoginSecurity openforread() throws SQLException
 {
  shelp=new sqlitehelper(con, DbName, null, DbVersion);
  sbase=shelp.getReadableDatabase();
  return this;
 }
 public LoginSecurity openforwrite() throws SQLException
 {
  shelp=new sqlitehelper(con, DbName, null, DbVersion);
  sbase=shelp.getWritableDatabase();
  return this;
 }
 public void close()
 {
  shelp.close();
 }
 public long insert(String s1, String s2)
 {
  ContentValues cv=new ContentValues();
  cv.put(Key_Name, s1);
  cv.put(Key_Pass, s2);
  return sbase.insert(DbTable, null, cv);
 }
 public String getPass(String pa)
 {
  String[] col=new String[]{Key_Name, Key_Pass};
  Cursor c=sbase.query(DbTable, col, null, null, null, null, null);
  String result="";
  int index=c.getColumnIndex(Key_Pass);
  for(c.moveToFirst();!c.isAfterLast();c.moveToNext())
  {
   result=c.getString(index);
  }
  return result;
  
 }
 
 public class sqlitehelper extends SQLiteOpenHelper
 {

   public sqlitehelper(Context context, String name,
    CursorFactory factory, int version) {
   super(context, name, factory, version);
   // TODO Auto-generated constructor stub
  }

   @Override
  public void onCreate(SQLiteDatabase db) {
   // TODO Auto-generated method stub
   db.execSQL(CreateTable);
   
  }

   @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
   // TODO Auto-generated method stub
   
  }
  
 }

}



LoginSeminar.java
package login.log;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class LoginSeminar extends Activity {
    /** Called when the activity is first created. */
 Button btsub,btcan;
 Button btnreg;
 EditText myuser,mypass;
 LoginSecurity ls;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btnreg=(Button)findViewById(R.id.button3);
        btcan=(Button)findViewById(R.id.button2);
        myuser=(EditText)findViewById(R.id.editText1);
        mypass=(EditText)findViewById(R.id.editText2);
        btsub=(Button)findViewById(R.id.button1);
        ls=new LoginSecurity(this);
        try
        {
        
        btsub.setOnClickListener(new View.OnClickListener() {
   
   public void onClick(View v) {
    // TODO Auto-generated method stub
    String x=myuser.getText().toString();
    String y=mypass.getText().toString();
    String temp="";
    ls.openforread();
    temp=ls.getPass(x);
    ls.close();
    if(temp.equals(y))
    {
     Toast.makeText(getApplicationContext(), "You are valid user", Toast.LENGTH_SHORT).show();
     
    }
    else
    {
     Toast.makeText(getApplicationContext(), "Sorry u r not valid user", Toast.LENGTH_SHORT).show();
    }
    
   }
  });
        }
        catch(Exception e)
        {
         Toast.makeText(getApplicationContext(), "ur login not exists pls register here", Toast.LENGTH_SHORT).show();
        }
        btnreg.setOnClickListener(new View.OnClickListener() {
   
   public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent i=new Intent(getApplicationContext(), RegisterAccount.class);
    startActivity(i);
    
   }
  });
    }
}



RegisterAccount.java
package login.log;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class RegisterAccount extends Activity {
 EditText nwuser,nwpass;
 Button btnreg;
 Button btnbk;
 LoginSecurity lss;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main1);
  nwuser=(EditText)findViewById(R.id.etnewuser);
  nwpass=(EditText)findViewById(R.id.etnewpass);
  btnreg=(Button)findViewById(R.id.btreg);
  btnbk=(Button)findViewById(R.id.btback);
  lss=new LoginSecurity(this);
  btnreg.setOnClickListener(new View.OnClickListener() {
   
   public void onClick(View v) {
    // TODO Auto-generated method stub
    try
    {
    String us=nwuser.getText().toString();
    String ps=nwpass.getText().toString();
    lss.openforwrite();
    lss.insert(us, ps);
    lss.close();
    Toast.makeText(getApplicationContext(), "Your Account Was Created", Toast.LENGTH_SHORT).show();
    }
    catch(Exception e)
    {
     e.printStackTrace();
    }
    
    
   }
  });
  btnbk.setOnClickListener(new View.OnClickListener() {
   
   public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent ii=new Intent(getApplicationContext(), LoginSeminar.class);
    startActivity(ii);
    
   }
  });
  
 }
 
 
}



main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/background"
    android:orientation="vertical"
    tools:context=".LoginSeminar" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="83dp"
        android:text="User Name"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="82dp"
        android:text="Password"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/textView1"
        android:layout_alignBottom="@+id/textView1"
        android:layout_alignParentRight="true"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/textView2"
        android:layout_alignBottom="@+id/textView2"
        android:layout_alignParentRight="true"
        android:ems="10" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/editText2"
        android:layout_marginTop="56dp"
        android:layout_toRightOf="@+id/textView2"
        android:text="Submit" />


    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button1"
        android:layout_alignBottom="@+id/button1"
        android:layout_marginLeft="55dp"
        android:layout_toRightOf="@+id/button1"
        android:text="Cancel" />



    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/button1"
        android:layout_marginTop="45dp"
        android:text="Register ur New Account" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_alignParentTop="true"
        android:text="Login Form"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="bold" />

</RelativeLayout>



main1.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:text="Password"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="89dp"
        android:text="User Name"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <EditText
        android:id="@+id/etnewuser"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/textView1"
        android:layout_alignBottom="@+id/textView1"
        android:layout_marginLeft="27dp"
        android:layout_toRightOf="@+id/textView1"
        android:ems="10" >

        <requestFocus />
    </EditText>


    <EditText
        android:id="@+id/etnewpass"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/textView2"
        android:layout_alignBottom="@+id/textView2"
        android:layout_alignLeft="@+id/etnewuser"
        android:layout_alignParentRight="true"
        android:ems="10" />


    <Button
        android:id="@+id/btreg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/etnewpass"
        android:layout_marginTop="71dp"
        android:layout_toRightOf="@+id/textView1"
        android:text="Register" />




    <Button
        android:id="@+id/btback"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btreg"
        android:layout_alignRight="@+id/btreg"
        android:layout_below="@+id/btreg"
        android:layout_marginTop="27dp"
        android:text="Back" />



    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/textView2"
        android:text="Registration Form"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="bold" />

</RelativeLayout>



AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="login.log"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".LoginSeminar"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".RegisterAccount"
            android:label="@string/app_name" >
            </activity>
    </application>

</manifest>




Thanks For Visiting....

Locate SQLite Database File in Android Eclipse

Hai Friends now i am going to share about how we can locate the SQLite database file in Eclipse IDE

Step 1:

Select Window -> Open Perspective -> DDMS


 Step 2:
 Select data from File Explorer tab




Step 3:
Select data folder from File Explorer tab



Step 4:
Again Select data folder from data tree folder


Step 4:

in data folder you have to choose your package folder name



Step 6:
Select Database .. Here you will see your database..

Thanks For Visiting...



Tuesday, 22 January 2013

Setting up Apache Tomcat Server for Servlet

Hai Friends Now i am going to share about how we can set up Apache tomcat server for Servlet Program..

Step 1:
First think we have to download Apache Tomcat...
You can go to home site of apache or Click here

Step 2:
Extract the downloaded zip file into C:

 
 Step 3:
create new folder in webapps folder... consider our folder name is "test"


Step 4:
create another folder within "test" folder.. set new folder name as "WEB-INF"






Step 5:
create "classes" folder within "WEB-INF" folder..








Step 6:
create web.xml file within WEB_INF folder.
and copy and paste following code into web.xml file






web.xml


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>Hello</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/Hello</url-pattern>
</servlet-mapping>
</web-app>


here Hello is a servlet class name..
each an every time we have to put entry in web.xml file for every new servlet class..



Step 7:
now we have to start the server..
open
Right click the my computer ->Properties ->Advanced System Settings ->Environment Variables

choose Path..and press edit button..





Step 8:
Copy the Java jdk path upto bin folder location from our computer..
and paste tat url into path text field..




Step 9:
now press "new " button give name as JAVA_HOME
and give java jdk path upto jdk folder...



Step 10:
now press "new " button give name as classpath
and give url of "servlet-api.jar" file.
This file is located on tomcat server's lib folder.





Step 11:
Now press ok in that window.. now move on to apache folder.. in bin folder we will find startup batch file



Step 12:

double click the startup file..now your server has started..



Step 13:
Open Browser window and type "localhost:8080"


Step 14:
It will display tomcat server home page..



Step 15:
Now we will test with Sample Program..

Step 16:
open note pad and copy following code

Hello.java


import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Hello extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
{
PrintWriter out=res.getWriter();
out.println("Its Working");
}
}









Step 17:
Save this file into classes folder as java file. and compile this file through cmd..













Step 18:
now class file has generated..

Step 19:
now we have to put servlet class name entry in web.xml file..
but we have already contain tat name.. so we no need to put new entry.













Step 20:
now we will run our program through browser
type following url in browser address bar

localhost:8080/test/hello


Step 21:
now it will display output



Friday, 18 January 2013

Insert, Update, Delete, View Operations in Oracle using Java JDBC

Here i am going to share how we can perform insert, update, delete and view operations on Oracle using Java JDBC...
Output Screens:









Step 1:
         We need some basic knowledge about Oracle database connectivity using Java,, if you know about that continue here.. otherwise if you need information   Refer here

Step 2:
         Create Table with follwing fields.
         Table Name : Employee
       
Column Name Column Type Description
empid Number Primary Key
empname Varchar
empsalary number

if you face any problem Refer Here

Step 3:
         Add required "ojdbc.jar" file into Eclipse Build path.
         For Your reference go here

Step 4:
         Create class DataModify into eclipse and paste following coding

DataModify
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

public class DataModify implements ActionListener
{
 
 JFrame mainframe=new JFrame("Database Operation");
 JPanel mainpanel=new JPanel();
 JButton insertbtn=new JButton("Insert");
 JButton viewbtn=new JButton("View");
 JButton modifybtn=new JButton("Modify");
 JButton deletebtn=new JButton("Delete");
 /* Variables For Insert Window*/
 JFrame insertframe=new JFrame("Insert into Database");
 JPanel insertpanel=new JPanel();
 JLabel empidlabel=new JLabel("Employee Id");
 JTextField empidtext=new JTextField(20);
 JLabel empnamelabel=new JLabel("Employee Name");
 JTextField empnametext=new JTextField(20);
 JLabel empsalarylabel=new JLabel("Employee Salary");
 JTextField empsalarytext=new JTextField(20);
 JButton insertsubmit=new JButton("Submit");
 //Variables for View Window
 JFrame viewframe=new JFrame("View Database Data");
 JPanel viewpanel=new JPanel();
 //Variables for Modify Window
 JFrame modifyframe=new JFrame("Modify the Data");
 JPanel modifypanel=new JPanel();
 JLabel mempidlabel=new JLabel("Employee Id");
 JTextField mempidtext=new JTextField(20);
 JLabel mempnamelabel=new JLabel("Employee Name");
 JTextField mempnametext=new JTextField(20);
 JLabel mempsalarylabel=new JLabel("Employee Salary");
 JTextField mempsalarytext=new JTextField(20);
 JButton modifysubmit=new JButton("Submit");
 //Variable for Delete Window
 JFrame deleteframe=new JFrame("Delete Data in Database");
 JPanel deletepanel=new JPanel();
 JLabel dempidlabel=new JLabel("Employee Id");
 JTextField dempidtext=new JTextField(20);
 JLabel dempnamelabel=new JLabel("Employee Name");
 JTextField dempnametext=new JTextField(20);
 JLabel dempsalarylabel=new JLabel("Employee Salary");
 JTextField dempsalarytext=new JTextField(20);
 JButton deletesubmit=new JButton("Submit");
 Connection con=null;
 Vector datacol=new Vector();
 Vector datarow=new Vector();
 JTable datatable;
 JScrollPane viewdata;
 
 public void init()
 {
  mainwindow();
  
  
 }
 public void mainwindow()
 {
  mainpanel.setBackground(Color.GRAY);
  mainpanel.setLayout(null);
  insertbtn.setBounds(300, 300, 100, 30);
  modifybtn.setBounds(450, 300, 100, 30);
  deletebtn.setBounds(600, 300, 100, 30);
  viewbtn.setBounds(800, 300, 100, 30);
  mainpanel.add(insertbtn);
  mainpanel.add(deletebtn);
  mainpanel.add(modifybtn);
  mainpanel.add(viewbtn);
  mainframe.add(mainpanel);
  mainframe.setSize(1350, 700);
  mainframe.setVisible(true);
  insertbtn.addActionListener(this);
  deletebtn.addActionListener(this);
  modifybtn.addActionListener(this);
  viewbtn.addActionListener(this);
  
  
 }
 public void insertwindow()
 {
 insertpanel.setBackground(Color.GRAY);
 empidlabel.setForeground(Color.WHITE);
 empnamelabel.setForeground(Color.WHITE);
 empsalarylabel.setForeground(Color.WHITE);
 insertpanel.setLayout(null);
 empidlabel.setBounds(400, 150, 100, 20);
 empidtext.setBounds(550, 150, 150, 30);
 empnamelabel.setBounds(400, 200, 100, 20);
 empnametext.setBounds(550, 200, 150, 30);
 empsalarylabel.setBounds(400, 250, 100, 20);
 empsalarytext.setBounds(550, 250, 150, 30);
 insertsubmit.setBounds(490, 300, 100, 30);
 
 insertpanel.add(empidlabel);
 
 insertpanel.add(empidtext);
 insertpanel.add(empnamelabel);
 insertpanel.add(empnametext);
 insertpanel.add(empsalarylabel);
 insertpanel.add(empsalarytext);
 insertpanel.add(insertsubmit);
 insertframe.add(insertpanel);
 
 insertframe.setSize(1350, 700);
 insertframe.setVisible(true);
 insertsubmit.addActionListener(this);
 insertframe.addWindowListener(new WindowAdapter()
 {
  public void windowClosing(WindowEvent e)
  {
   mainframe.setVisible(true);
  }
 }
 );
 }
 public void viewwindow()
 {
  
  datacol.removeAllElements();
  datarow.removeAllElements();
  OpenDatabase();
  try
  {
  Statement st=con.createStatement();
  ResultSet rs=st.executeQuery("select * from Employee");
  ResultSetMetaData rms=rs.getMetaData();
  int cols=rms.getColumnCount();
  for(int i=1;i<=cols;i++)
  {
   datacol.addElement(rms.getColumnName(i));
  }
  while(rs.next())
  {
   Vector row=new Vector(cols);
   for(int i=1;i<=cols;i++)
   {
    row.addElement(rs.getObject(i));
   }
   datarow.addElement(row);
  }
  datatable=new JTable(datarow,datacol);
  viewdata=new JScrollPane(datatable);
  
  }
  catch(Exception e)
  {
   JOptionPane.showConfirmDialog(null, "Problem in Database connectivity or Data", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
   
  }
  viewpanel.setBackground(Color.GRAY);
  viewpanel.setLayout(null);
  viewdata.setBounds(20, 50, 1250, 600);
  viewpanel.add(viewdata);
  viewframe.add(viewpanel);
  viewframe.setSize(1350, 700);
  viewframe.setVisible(true);
  viewframe.addWindowListener(new WindowAdapter()
  {
   public void windowClosing(WindowEvent e)
   {
    mainframe.setVisible(true);
   }
  });
  
  
  
  
 }
 public void modifywindow()
 {
  mempnametext.disable();
  mempsalarytext.disable();
  mempidtext.setText("");
  mempnametext.setText("");
  mempsalarytext.setText("");
  modifypanel.setBackground(Color.GRAY);
  mempidlabel.setForeground(Color.WHITE);
  mempnamelabel.setForeground(Color.WHITE);
  mempsalarylabel.setForeground(Color.WHITE);
  modifypanel.setLayout(null);
  mempidlabel.setBounds(400, 150, 100, 20);
  mempidtext.setBounds(550, 150, 150, 30);
  mempnamelabel.setBounds(400, 200, 100, 20);
  mempnametext.setBounds(550, 200, 150, 30);
  mempsalarylabel.setBounds(400, 250, 100, 20);
  mempsalarytext.setBounds(550, 250, 150, 30);
  modifysubmit.setBounds(490, 300, 100, 30);
  
  modifypanel.add(mempidlabel);
  
  modifypanel.add(mempidtext);
  modifypanel.add(mempnamelabel);
  modifypanel.add(mempnametext);
  modifypanel.add(mempsalarylabel);
  modifypanel.add(mempsalarytext);
  modifypanel.add(modifysubmit);
  modifyframe.add(modifypanel);
  
  modifyframe.setSize(1350, 700);
  modifyframe.setVisible(true);
  modifysubmit.addActionListener(this);
  modifyframe.addWindowListener(new WindowAdapter()
  {
   public void windowClosing(WindowEvent e)
   {
    mainframe.setVisible(true);
   }
  });
  mempidtext.addActionListener(this);
  
 }
 public void deletewindow()
 {
  dempnametext.disable();
  dempsalarytext.disable();
  dempidtext.setText("");
  dempnametext.setText("");
  dempsalarytext.setText("");
  deletepanel.setBackground(Color.GRAY);
  dempidlabel.setForeground(Color.WHITE);
  dempnamelabel.setForeground(Color.WHITE);
  dempsalarylabel.setForeground(Color.WHITE);
  deletepanel.setLayout(null);
  dempidlabel.setBounds(400, 150, 100, 20);
  dempidtext.setBounds(550, 150, 150, 30);
  dempnamelabel.setBounds(400, 200, 100, 20);
  dempnametext.setBounds(550, 200, 150, 30);
  dempsalarylabel.setBounds(400, 250, 100, 20);
  dempsalarytext.setBounds(550, 250, 150, 30);
  deletesubmit.setBounds(490, 300, 100, 30);
  
  deletepanel.add(dempidlabel);
  
  deletepanel.add(dempidtext);
  deletepanel.add(dempnamelabel);
  deletepanel.add(dempnametext);
  deletepanel.add(dempsalarylabel);
  deletepanel.add(dempsalarytext);
  deletepanel.add(deletesubmit);
  deleteframe.add(deletepanel);
  
  deleteframe.setSize(1350, 700);
  deleteframe.setVisible(true);
  deletesubmit.addActionListener(this);
  dempidtext.addActionListener(this);
  deleteframe.addWindowListener(new WindowAdapter()
  {
   public void windowClosing(WindowEvent e)
   {
    mainframe.setVisible(true);
   }
  });  
  
 }
 public void insertdata(int eid, String ename, int esalry)
 {
  try
  {
  Statement st=con.createStatement();
  st.executeUpdate("insert into Employee values("+eid+",'"+ename+"',"+esalry+")");
  JOptionPane.showConfirmDialog(null, "Your Data Has been Inserted", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.PLAIN_MESSAGE);
  } 
  catch(Exception e)
  {
   JOptionPane.showConfirmDialog(null, "Problem in Database connectivity or Data", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
  }
 }
 public void deletedata(int eid)
 {
  try
  {
   Statement st=con.createStatement();
   st.executeUpdate("delete from Employee where empid="+eid);
   JOptionPane.showConfirmDialog(null, "Your Data Has been Deleted", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.PLAIN_MESSAGE);
  }
  catch(Exception e)
  {
   JOptionPane.showConfirmDialog(null, "Problem in Database connectivity or Data", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
  }
 }
 public void modifydata(int eid, String ename, int esal)
 {
  try
  {
   Statement st=con.createStatement();
   st.executeUpdate("update Employee set empname='"+ename+"', empsalary="+esal+" where empid="+eid);
   JOptionPane.showConfirmDialog(null, "Your Data Has been Modified", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.PLAIN_MESSAGE);
  }
  catch(Exception e)
  {
   JOptionPane.showConfirmDialog(null, "Problem in Database connectivity or Data", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
  }
 }
 public void OpenDatabase()
 {
  
  try
  {
   Class.forName("oracle.jdbc.driver.OracleDriver");
   con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","Partha","sarathi");
   
  }
  catch(Exception e)
  {
   System.out.println(e);
  }
 }
 public void CloseDatabase()
 {
  try {
   con.close();
  } catch (SQLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  
 }
 @Override
 public void actionPerformed(ActionEvent arg0) {
  // TODO Auto-generated method stub
  if(arg0.getSource()==insertbtn)
  {
   mainframe.setVisible(false);
   insertwindow();
  }
  if(arg0.getSource()==viewbtn)
  {
   mainframe.setVisible(false);
   viewwindow();
  }
  if(arg0.getSource()==modifybtn)
  {
   mainframe.setVisible(false);
   modifywindow();
  }
  if(arg0.getSource()==deletebtn)
  {
   mainframe.setVisible(false);
   deletewindow();
  }
  if(arg0.getSource()==insertsubmit)
  {
   int empid=Integer.parseInt(empidtext.getText());
   String ename=empnametext.getText();
   int esalary=Integer.parseInt(empsalarytext.getText());
   try
   {
   OpenDatabase();
   insertdata(empid,ename,esalary);
   
   CloseDatabase();
   
   }
   catch(Exception e)
   {
    System.out.println(e);
   }
   empidtext.setText("");
   empnametext.setText("");
   empsalarytext.setText("");
  
   
   
  }
  if(arg0.getSource()==modifysubmit)
  {
   int empid=Integer.parseInt(mempidtext.getText());
   String ename=mempnametext.getText();
   int esalary=Integer.parseInt(mempsalarytext.getText());
   OpenDatabase();
   modifydata(empid,ename,esalary);
   CloseDatabase();
  }
  if(arg0.getSource()==deletesubmit)
  {
   int eid=Integer.parseInt(dempidtext.getText());
   OpenDatabase();
   deletedata(eid);
   CloseDatabase();
   eid=0;
  }
  if(arg0.getSource()==mempidtext)
  {
   int eid=Integer.parseInt(mempidtext.getText());
   try
   {
   OpenDatabase();
   Statement st=con.createStatement();
   ResultSet rs=st.executeQuery("Select * from Employee where empid="+eid);
   if(rs.next())
   {
   mempnametext.setText(rs.getString("empname"));
   mempsalarytext.setText(String.valueOf(rs.getInt("empsalary")));
   }
   CloseDatabase();
   mempnametext.enable();
   mempsalarytext.enable();
   }
   catch(Exception e)
   {
 
    JOptionPane.showConfirmDialog(null, "Problem in Database connectivity or Data", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
   }
  }
  if(arg0.getSource()==dempidtext)
  {
   int eid=Integer.parseInt(dempidtext.getText());
   try
   {
    OpenDatabase();
    Statement st=con.createStatement();
    ResultSet rs=st.executeQuery("Select * from Employee where empid="+eid);
    if(rs.next())
    {
    dempnametext.setText(rs.getString("empname"));
    dempsalarytext.setText(String.valueOf(rs.getInt("empsalary")));
    }
    CloseDatabase();
    
    
   }
   catch(Exception e)
   {
    JOptionPane.showConfirmDialog(null, "Problem in Database connectivity or Data", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
   }
  }
  
 }
 public static void main(String args[])
 {
  DataModify dm=new DataModify();
  dm.init();
  
 }
  
}
Step 5:
Change the username and Password for Database...
replace your username for "testuser" and replace your password for "test"


Thanks for Visiting....