Sunday, September 23, 2007

SEARCH DATA

/*PROGRAME TO SEARCH PARTICULAR DATA*/



import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
class Search
{
public Search()
{
final JFrame jf = new JFrame("Search");
jf.setSize(800,500);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.getContentPane().setLayout(null);
Font f1 = new Font("sansserif",Font.BOLD,24);
Label l3 = new Label("ADDRESS BOOK");
l3.setBounds(250,10,800,40);
l3.setFont(f1);
jf.getContentPane().add(l3);
final TextArea ta = new TextArea();
ta.setBounds(0,120,1000,600);
ta.setEditable(false);
jf.getContentPane().add(ta);
Label l = new Label ("SEARCH BY NAME:");
l.setBounds(5,60,110,30);
jf.getContentPane().add(l);
final TextField tf = new TextField();
tf.setBounds(130,60,100,30);
jf.getContentPane().add(tf);
Label l1 = new Label ("TELEPHONE:");
l1.setBounds(250,60,100,30);
jf.getContentPane().add(l1);
final TextField tf1 = new TextField();
tf1.setBounds(350,60,100,30);
jf.getContentPane().add(tf1);
Button b1 = new Button("SEARCH");
b1.setBounds(480,60,60,30);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
String s6,s,s1,s3,s4,d,s0="1233";
long s2,s5;
s = tf.getText();
s6=tf1.getText();
if(s6.equals(""))
s5=Long.parseLong(s0);
else
s5 = Long.parseLong(tf1.getText());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
final Connection con =DriverManager.getConnection("jdbc:odbc:student");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("Select * From addressb");
while(rs.next())
{
s1 = rs.getString(1);
s2 = rs.getLong(2);
s3 = rs.getString(3);
s4 = rs.getString(4);
d = rs.getString(5);
System.out.println("gotstring");
if((s1.equals(s))||(s2==s5))
{
System.out.println("string equal");
ta.append("NAME : "+s1+"\n");
ta.append("PHONE NO : "+s2+"\n");
ta.append("ADDRESS : "+s3+"\n");
ta.append("EMAIL ID : "+s4+"\n");
ta.append("DATE OF BIRTH : "+s5+"\n");
ta.append("**************************************"+"\n");
}
}
}
catch(Exception e1){System.out.println("ERROR="+e1);
}
}
});
jf.getContentPane().add(b1);
Button b2 = new Button("ADD");
b2.setBounds(550,60,60,30);
b2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
Add a = new Add();
}
catch(Exception e2){}
}
});
jf.getContentPane().add(b2);
Button b3 = new Button("EXIT");
Button b4 = new Button("DELETE");
b4.setBounds(620,60,60,30);
b4.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e4)
{
try
{
Delete d = new Delete();
}
catch(Exception e5){}
}
});
jf.getContentPane().add(b4);
b3.setBounds(690,60,60,30);
b3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e2)
{
try
{
System.exit(0);
}
catch(Exception e3){}
}
});
jf.getContentPane().add(b3);
jf.show();
}
}

DELETE DATA

/*PROGRAME TO DELETE DATA*/

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
class Delete
{
public Delete() throws Exception
{
final JFrame jf = new JFrame("DELETE");
jf.setSize(600,500);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.getContentPane().setLayout(null);
Font f1 = new Font("sansserif",Font.BOLD,24);
Label l3 = new Label("ADDRESS BOOK");
l3.setBounds(200,10,800,40);
l3.setFont(f1);
jf.getContentPane().add(l3);
Label l = new Label ("DELETE BY NAME:");
l.setBounds(170,110,110,30);
jf.getContentPane().add(l);
final TextField tf = new TextField();
tf.setBounds(300,110,150,30);
jf.getContentPane().add(tf);
Label l1 = new Label ("TELEPHONE:");
l1.setBounds(170,160,100,30);
jf.getContentPane().add(l1);
final TextField tf1 = new TextField();
tf1.setBounds(300,160,150,30);
jf.getContentPane().add(tf1);
Button b1 = new Button("DELETE");
b1.setBounds(200,210,60,30);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
long s2,s5;
String s0,s6;
s0 = tf.getText();
s6=tf1.getText();
Connection cn;
Statement st;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("jdbc:odbc:student");
st=cn.createStatement();
st.executeUpdate("Delete from addressb where name='"+s0+"'");
st.close();
}
catch(Exception e1){System.out.println("ERROR="+e1);
}
}
});
jf.getContentPane().add(b1);
Button b2 = new Button("ADD");
b2.setBounds(300,210,60,30);b2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
Add a = new Add();
}
catch(Exception e2)
{}
}
});
jf.getContentPane().add(b2);
Button b3 = new Button("EXIT");
b3.setBounds(400,210,60,30);
b3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e2)
{
try
{
System.exit(0);
}
catch(Exception e3)
{}
}
});
jf.getContentPane().add(b3);
jf.show();
}
}

ADD RECORD

/*PROGRAME TO ENTER NEW INFORMATION*/

import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class Add
{
public Add() throws Exception
{
final TextField tf1,tf2,tf3,tf4,tf5;
Label l1,l2,l3,l4,l5,l6;
Button b1,b2,b3;
final JFrame f;
f= new JFrame("ADDRESS BOOK");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(600,500);
f.getContentPane().setLayout(null);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
final Connection con =DriverManager.getConnection("jdbc:odbc:student");
Font f1 = new Font("sansserif",Font.BOLD,24);
l6 = new Label("ADDRESS BOOK");
l6.setBounds(200,10,800,40);
l6.setFont(f1);
f.getContentPane().add(l6);
l1= new Label("NAME :");
l1.setBounds(150,100,100,30);
f.getContentPane().add(l1);
tf1 = new TextField();
tf1.setBounds( 250,100,200,30);
f.getContentPane().add(tf1);
l2= new Label("PHONE NO. :");
l2.setBounds(150,150,100,30);
f.getContentPane().add(l2);
tf2 = new TextField();
tf2.setBounds( 250,150,200,30);
f.getContentPane().add(tf2);
l3= new Label("ADDRESS :");
l3.setBounds(150,200,100,30);
f.getContentPane().add(l3);
tf3 = new TextField();
tf3.setBounds( 250,200,200,30);
f.getContentPane().add(tf3);
l4= new Label("EMAIL Id :");
l4.setBounds(150,250,100,30);
f.getContentPane().add(l4);
tf4 = new TextField();
tf4.setBounds( 250,250,200,30);
f.getContentPane().add(tf4);
l5= new Label("BIRTH DATE:");
l5.setBounds(150,300,100,30);
f.getContentPane().add(l5);
tf5 = new TextField();
tf5.setBounds( 250,300,200,30);
f.getContentPane().add(tf5);
b1 = new Button("ENTER");
b1.setBounds(150,350,80,30);
b1.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
String s1,s2,s3,s4,s5;
s1 = tf1.getText();
s2 = tf2.getText();
s3 = tf3.getText();
s4 = tf4.getText();
s5 = tf5.getText();
PreparedStatement ps = con.prepareStatement("insert into addressb values(?,?,?,?,?)");
ps.setString(1,s1);
ps.setString(2,s2);
ps.setString(3,s3);
ps.setString(4,s4);
ps.setString(5,s5);
int i = ps.executeUpdate();
System.out.println("Row Updated:"+i);
tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");
tf5.setText("");
}
catch(Exception e1){System.out.println("ERROR:"+e1);
}
}
});
f.getContentPane().add(b1);
b2 = new Button("SEARCH");
b2.setBounds(260,350,80,30);
b2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e2)
{
try
{
Search b= new Search();
}
catch(Exception e3){}
}
});
f.getContentPane().add(b2);
b3 = new Button("EXIT");
b3.setBounds(370,350,80,30);
b3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e2)
{
try
{
System.exit(0);
}
catch(Exception e3)
{}
}
});
f.getContentPane().add(b3);
f.show();
}
}

DATA MODIFICATION



/*PROGRAME SHOWING ADD , DELETE , SEARCH AND BUTTONS*/



import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class start
{
public start() throws Exception
{
Button b1,b2,b3;
JFrame jf;
jf=new JFrame("START");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(500,500);
jf.getContentPane().setLayout(null);
Font f1 = new Font("sansserif",Font.BOLD,24);
Label l3 = new Label("ADDRESS BOOK");
l3.setBounds(150,10,800,40);
l3.setFont(f1);
jf.getContentPane().add(l3);
b1 = new Button("ADD");
b1.setBounds(200,150,100,40);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
Add a = new Add();
}
catch(Exception e2){}
}
});
b2 = new Button("SEARCH");
b2.setBounds(200,100,100,40);
b2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e1)
{
try
{
Search b = new Search();
}
catch(Exception e3)
{}
}
});
b3 = new Button("DELETE");
b3.setBounds(200,200,100,40);
b3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e2)
{
try
{
Delete c = new Delete();
}
catch(Exception e4)
{}
}
});
jf.getContentPane().add(b1);
jf.getContentPane().add(b2);
jf.getContentPane().add(b3);
jf.show();
}
}

LOGON

/*SECOND PROGRAME SHOWS LOGON PAGE*/


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class loginb
{
public loginb()
{
try
{
final TextField tf1,tf2;
Label l1,l2,l3;
Button b1;
final JFrame f = new JFrame("ADDRESS BOOK");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(500,500);
f.getContentPane().setLayout(null);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Final Connection con =DriverManager.getConnection("jdbc:odbc:student");
final Statement st = con.createStatement();
Font f1 = new Font("sansserif",Font.BOLD,24);
l3 = new Label("ADDRESS BOOK");
l3.setBounds(150,10,800,40);
l3.setFont(f1);
f.getContentPane().add(l3);
l1= new Label("USER NAME :");
l1.setBounds(100,200,100,30);
f.getContentPane().add(l1);
tf1 = new TextField();
tf1.setBounds(200,200,100,30);
f.getContentPane().add(tf1);
l2= new Label("PASSWORD :");
l2.setBounds(100,250,100,30);
f.getContentPane().add(l2);
tf2 = new TextField();
tf2.setEchoChar('*');
tf2.setBounds(200,250,100,30);
f.getContentPane().add(tf2);
b1 = new Button("LOGIN");
b1.setBounds(200,300,100,30);
f.getContentPane().add(b1);
b1.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
String s1 = tf1.getText();
String s2 = tf2.getText();
System.out.println("got data ");
ResultSet rs = st.executeQuery("Select * From login");
System.out.println("table select");
while(rs.next())
{
String s3= rs.getString(1);
String s4=rs.getString(2);
System.out.println("data entered"+s1+" "+s2);
System.out.println("inside while"+s3+" "+s4);
if(s3.equals(s1) && s4.equals(s2))
{
try
{
f.hide();
start s = new start();
}
catch(Exception e3)
{}
}
}
tf1.setText("");
tf2.setText("");
}
catch(Exception e1){System.out.println("ERROR 1"+e1);
}
}
});
f.show();
}
catch(Exception e2){System.out.println("ERROR 2"+e2);
}
}
}

MAIN CLASS

/*FIRST PROGRAME WITH MAIN CLASS*/

import java.awt.*;
import java.awt.event.*;
class first extends Frame implements ActionListener
{
Button b;
Toolkit t;
Image i,i1,i2;
Label a,a1,a2;
public first()
{
Color col=new Color(100,200,200);
setBackground(col);
a=new Label("ADDRESS BOOK");
a1=new Label("(DEVELOPED BY)");
a2=new Label("JAGJEET SINGH RAJINDER PAL SINGH TEJINDER SINGH");
b=new Button("CLICK TO PROCEED");
t=Toolkit.getDefaultToolkit();
i=t.getImage("f:/jaggi/1.jpg");
i1=t.getImage("f:/jaggi/2.jpg");
i2=t.getImage("f:/jaggi/3.jpg");
add(a);
add(a1);
add(a2);
add(b);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
loginb b=new loginb();
}
public void paint(Graphics g)
{
a.setBounds(280,40,400,50);
a1.setBounds(280,80,700,70);
a2.setBounds(60,150,990,50);
b.setBounds(230,530,350,50);
Font f=new Font("Arial",Font.ITALIC,30);
a.setFont(f);
a1.setFont(f);
Font h=new Font("Arial",Font.ITALIC,20);
a2.setFont(h);
g.drawImage(i,10,200,this);
g.drawImage(i1,290,200,this);
g.drawImage(i2,560,200,this);
}
}
class f
{
public static void main(String ap[])
{
first d=new first();
d.setSize(800,600);
d.setVisible(true);
}
}

Systems Requirements

SYSTEMS REQUIREMENTS

The project Students records management system has been prepared by using the following versions of software and hardware .Hence to use and modify the package at any other installation the hardware and software requirement would be as follows:


COMPUTER HARDWARE
REQUIREMENTS

1. COMPUTER PC/AT
2. MICROPROCESSOR 80486 D*Z /100MHZ
3. CD ROM RW
4. RAM 128MB
5. KEYBOARD 105KEYS
6. V.D.U LG 14” MONOCHROME”
7. PRINTER L & G
8. KEYBOARD 132COLUMNS,LASER
9. MOUSE OPTICAL



COMPUTER SOFTWARE
REQUIREMENTS


1. OPERATING SYSTEM: WINDOWS 98/NT, XP
2. WORD PROCESSOR: MS -WORD
3. FRONT END : JAVA
4. BACK END : MS-ACCESS

Preface

This PROJECT REPORT is based on the work and activities performed for successful completion of the major project. The report gives the comprehensive study of the project.



"STUDENT’S ADDRESS BOOK"

The main aim of the project is to provide general knowledge and enable the student to be aware of the practical aspects of the studies carried out during the degree. We did this work with the hope that this will help the reader in understanding the basic concepts of DATABASE in Java. The precious knowledge gained during the development this project will be advantageous to us in our future and enhance our knowledge.

Certificate

This is to certify that the work presented in the project report entitled “STUDENT’S ADDRESS BOOK” submittd by Mr. Jagjeet Singh & Mr. Rajinder Pal Singh & Tejinder Singh in partial fulfillment of requirements for the award of Post Graduate degree of Master of Science in Information Technology of Vaishnoo Maa Computers, Patiala, is an authentic record of students own work carried out under my supervision and guidance. The matter embodied in report has not been submitted anywhere for award of any other degree.

Acknowledgement

Words fail me to express my deep sense of gratitude and indebtedness to Mr.Rajesh Khanna (Lecturer, Vaishnoo Maa Computers, Patiala) for his mature, able and invaluable guidance, his all out help, painstaking efforts and deep insight into the problem and thus improving the quality of this work at all stages, for his persistent encouragement that helped me to present this report in the present form.

I am also thankful to my colleagues Mr. Gurpal Singh and Vikram Gupta for their continuous encouragement during the study.

My special thanks are due to Mr. Rajesh Khanna(Lecturer, Vaishnoo Maa Computer, Patiala) who helped me directly or indirectly in the various stages of this study.