prisoner management system
DESCRIPTION
This project was windows based application. In this project we had developed an application that will manage the details of prisoner and the warden in a cell. This system was developed in Java and for data base MS Access 2007 we had used.TRANSCRIPT
[ ] May 2, 2012
APIIT SD INDIA
CE00396-1-OOEDP
Object Oriented & Event Driven Programming
Lecturer
Gaurav Gambhir
Submitted by:
Prince Kumar Intake no: PT1082219
E-mail id: [email protected]
1 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
ACKNOWLEDGEMENT
The satisfaction that accompanies that the successfulCompletion of any task would be incomplete without theMention of people whose ceaseless cooperation made itPossible, whose constant guidance and encouragementCrown all efforts with success.
We are grateful to our project guide Mr. Gaurav Gambhir
For the Guidance, inspiration and constructive suggestions that Helpful us in the preparation of this project. We also thank our colleagues who have helped in successful Completion of the project.
Prince Kumar
2 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
ABSTRACT
“Secure prisons are essential to making our justice system an effective weapon against crime. When Prisoners – convicted or awaiting trial – are entrusted to your care, they must know and the public must know that they will remain there until they are legally discharged …”
Prisoner Management system has never been easier .The prisoner module provides management tools and reporting specifically design for modern law enforcement. The security of a prison should go further than preventing the effective control of communication of prisoners with the outside world to prevent the continuation of organized crime, or intimidation of witnesses or victims by incarcerated prisoners.
This report describes implementation of a Prisoner Management system. We used the UML Diagrams model to design a database that will store and organize the Prisoner data. We have created the database using SQL and populated it with some sample Data. The system can keep track of Add Prisoner, Delete Prisoner, Find Prisoner, Release Prisoner, Add Warden, Delete Prisoner, and Find Prisoner And the relationships between them. Using Awt Java, java sql and JDBC, we have created an Internet-based graphical user interface that allows Warden to access the system remotely. This management system includes two different action first is Prisoner and second is Warden. They both perform different operation. In which warden and prisoner are handled. Like user can handle warden by adding, deleting, updating the status and many more .And in prisoner user can add, delete, update, find, release, edit. Which we discuss in further i.e., assignment.
3 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
Table of Contents
S.no Topic Page no:
1. UML Diagram 5-9
1.1. Use case 51.2. Class Diagram 6-71.3. Activity Diagram 81.4. Sequence Diagram 9
2. Story Boarding 10
3. Source Code 11-28
4. Sample Output 29-30
5. Assumptions 31
6. Conclusion 32
7. References 33
4 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
1. UML Diagram1.1 Use Case Diagram...
5 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
1.2 Class Diagram …..
ShowWarden PMS Prisondbase
6 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
Prisoner showpRecord
7 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
1.3 Activity Diagram …..
8 Asia Pacific Institute of Information Technology
Execute Stand Alone Application
Welcome Frame
Decision by user
Prisoner Warden
Add
Delete
Find
Release
Display
Add
Warden
Display
Delete
[ ] May 2, 2012
1.4 Sequence Diagram..
9 Asia Pacific Institute of Information Technology
A sequence diagram in a Unified Modeling Language (UML) is a kind of interaction diagram that shows how processes operate with one another and in what order. It is a construct of a Message Sequence Chart. A sequence diagram shows object interactions arranged in time sequence. It depicts the objects and classes involved in the scenario and the sequence of messages exchanged between the objects needed to carry out the functionality of the scenario. Sequence diagrams typically are associated with use case realizations in the Logical View of the system under development.
Sequence diagrams are sometimes called event diagrams, event scenarios, and timing diagrams
[ ] May 2, 2012
2. Story Boarding
Delete Search Update Display
10 Asia Pacific Institute of Information Technology
For Prisoner
Window
For Warden Window
For Closing the window
Add
Prisoner
[ ] May 2, 2012
3. Source code
Save as : PMS.java
import java.awt.Color;import java.awt.Container;import java.awt.Rectangle;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.Date;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.util.Calendar;
import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;
public class PMS extends JFrame implements ActionListener {
Container c;JPanel pnlWarden;JLabel name , ptype;JTextField txtname , txtwardenid;JButton btndisplay, btnupdate, btnsearch, btndelete, btnadd ;JComboBox cborank;
prisondbase db=new prisondbase();
public PMS(){
c=getContentPane();c.setLayout(null);
pnlWarden=new JPanel();pnlWarden.setLayout(null);pnlWarden.setBounds(new Rectangle(100,10,700,600));pnlWarden.setBackground(Color.lightGray);c.add(pnlWarden);name=new JLabel("Warden ID: ");name.setBounds(new Rectangle(90,200,100,30));
11 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
pnlWarden.add(name);c.add(pnlWarden);name = new JLabel("Warden Name: ");name.setBounds(new Rectangle(90,250,100,30));pnlWarden.add(name);//name = new JLabel("Date Of Birth: ");//name.setBounds(new Rectangle(90,150,100,30));//pnlWarden.add(name);name = new JLabel("Rank :");
name.setBounds(new Rectangle(90,300,100,30)); pnlWarden.add(name); txtname = new JTextField(); txtname.setBounds(new Rectangle(200,250,120,30)); pnlWarden.add(txtname); txtwardenid = new JTextField(); txtwardenid.setBounds(new Rectangle(200,200,120,30)); pnlWarden.add(txtwardenid); btnadd = new JButton("Add"); btnadd.setBounds(new Rectangle(220, 400 , 100 ,30 )); pnlWarden.add(btnadd); btndelete = new JButton("Delete"); btndelete.setBounds(new Rectangle(150, 100 , 90 ,30 )); pnlWarden.add(btndelete); btnsearch = new JButton("Search"); btnsearch.setBounds(new Rectangle(270, 100 , 90 ,30 )); pnlWarden.add(btnsearch); btnupdate = new JButton("Update"); btnupdate.setBounds(new Rectangle(390, 100 , 90 ,30 )); pnlWarden.add(btnupdate); btndisplay = new JButton("Display"); btndisplay.setBounds(new Rectangle(510, 100 , 90 ,30 )); pnlWarden.add(btndisplay); //ptype = new JLabel("Rank"); //JLabel.setBounds ((new Rectangle(90,200,100,30)); cborank = new JComboBox(); cborank.setBounds(new Rectangle(200 , 300 , 100 , 30 )); cborank.addItem("1"); cborank.addItem("2"); cborank.addItem("3");
12 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
cborank.addItem("4"); cborank.addItem("5"); pnlWarden.add(cborank); btndisplay.addActionListener(this); btnupdate.addActionListener(this); btnsearch.addActionListener(this); btndelete.addActionListener(this); btnadd.addActionListener(this);
pnlWarden.setVisible(true);
}
public static void main(String[] args) {PMS pm=new PMS();pm.setSize(1000, 700);pm.setVisible(true);
}
public void actionPerformed(ActionEvent ev) {
if(ev.getSource()==btnadd){
Connection con=null; PreparedStatement ptmt; int i=0; try { con=db.getDBConnection(); String sql="INSERT INTO WARDEN VALUES (?,?,?)"; ptmt=con.prepareStatement(sql); ptmt.setString(1, txtwardenid.getText()); ptmt.setString(2, txtname.getText()); ptmt.setString(3,(String) cborank.getSelectedItem()); i=ptmt.executeUpdate(); if(i>0) { JOptionPane.showMessageDialog(null, "Warden Inserted Successfully"); } else { JOptionPane.showMessageDialog(null, "Warden Not Inserted Successfully");
13 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
}
} catch (Exception e1) {e1.printStackTrace();
}}if(ev.getSource()==btnsearch){
System.out.println("Clicked");Connection con=null;
PreparedStatement ptmt; try { con=db.getDBConnection(); String sql="SELECT * FROM WARDEN WHERE Warden_Id LIKE ?"; ptmt=con.prepareStatement(sql); ptmt.setString(1, txtwardenid.getText()); ResultSet rs=ptmt.executeQuery(); while(rs.next()) { txtwardenid.setText(rs.getString(1)); txtname.setText(rs.getString(2)); cborank.setSelectedItem(rs.getString(3)); }
} catch (Exception e1) {e1.printStackTrace();
}}if(ev.getSource()==btndelete){
int i=0;try {
Connection con=db.getDBConnection();String sql="DELETE * FROM WARDEN WHERE Warden_Id LIKE ?";PreparedStatement ptmt=con.prepareStatement(sql);ptmt.setString(1, txtwardenid.getText());i=ptmt.executeUpdate();
} catch (Exception e2) {e2.printStackTrace();
}
if(i>0) { JOptionPane.showMessageDialog(null, "Warden DELETED Successfully");
14 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
} else { JOptionPane.showMessageDialog(null, "Warden NOT DELETED Successfully");
}
}
if(ev.getSource()==btndisplay){
showWardens ws=new showWardens();ws.setVisible(true);ws.setSize(700, 500);
}
}
}
Save as : prisonedbase.java
import java.sql.Connection;
import java.sql.*;
public class prisondbase {
private static final String driverclass="sun.jdbc.odbc.JdbcOdbcDriver";static String url = "jdbc:odbc:PRINCE";
public Connection getDBConnection() { Connection con=null; try { Class.forName(driverclass); con=DriverManager.getConnection(url); } catch (Exception e) {
// TODO: handle exception e.printStackTrace();
} return con; }}
15 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
Save as : Prisoner.java
import javax.swing.*;
import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.Date;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.util.Calendar;
public class Prisoner extends JFrame implements ActionListener{
/** * */private static final long serialVersionUID = 1L;Container c;
JPanel pnlPrisoner; JLabel lblpid , lblname , lblsecuritylevel , lbldateofprison , lblrelease ; JTextField txtid , txtname ; JComboBox cboseclevel , cboddp , cbommp , cboyyp , cboddr , cbommr , cboyyr ; JButton btndisplay, btnupdate, btnsearch, btndelete, btnadd ; prisondbase mydb=new prisondbase(); public Prisoner() {
c=getContentPane(); c.setLayout(null); pnlPrisoner=new JPanel(); pnlPrisoner.setBounds(new Rectangle(10,10,780,600)); pnlPrisoner.setLayout(null); pnlPrisoner.setBackground(Color.LIGHT_GRAY); lblpid=new JLabel("Prisoner ID"); lblname=new JLabel("Prisoner Name"); lblsecuritylevel=new JLabel("Security Type"); lbldateofprison=new JLabel( "Date Of prison"); lblrelease=new JLabel("Date of release"); txtid=new JTextField(); txtname=new JTextField();
16 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
cboseclevel=new JComboBox(); cboseclevel.addItem("High"); cboseclevel.addItem("Low"); cboddp=new JComboBox(); cboddp.addItem("Day");
cboddp.addItem("1");cboddp.addItem("2");cboddp.addItem("3");cboddp.addItem("4");cboddp.addItem("5");cboddp.addItem("6");cboddp.addItem("7");cboddp.addItem("8");cboddp.addItem("9");cboddp.addItem("10");cboddp.addItem("11");cboddp.addItem("12");cboddp.addItem("13");cboddp.addItem("14");cboddp.addItem("15");cboddp.addItem("16");cboddp.addItem("17");cboddp.addItem("18");cboddp.addItem("19");cboddp.addItem("20");cboddp.addItem("21");cboddp.addItem("23");cboddp.addItem("24");cboddp.addItem("25");cboddp.addItem("26");cboddp.addItem("27");cboddp.addItem("28");cboddp.addItem("29");cboddp.addItem("30");cboddp.addItem("31");
cbommp=new JComboBox(); cbommp.addItem("Month");
cbommp.addItem("1");cbommp.addItem("2");cbommp.addItem("3");cbommp.addItem("4");cbommp.addItem("5");cbommp.addItem("6");cbommp.addItem("7");cbommp.addItem("8");cbommp.addItem("9");cbommp.addItem("10");cbommp.addItem("11");cbommp.addItem("12");
17 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
cboyyp=new JComboBox(); cboyyp.addItem("Year");
cboyyp.addItem("1980");cboyyp.addItem("1981");cboyyp.addItem("1982");cboyyp.addItem("1983");cboyyp.addItem("1984");cboyyp.addItem("1985");cboyyp.addItem("1986");cboyyp.addItem("1987");cboyyp.addItem("1988");cboyyp.addItem("1989");cboyyp.addItem("1990");cboyyp.addItem("1991");cboyyp.addItem("1992");cboyyp.addItem("1993");cboyyp.addItem("1994");cboyyp.addItem("1995");cboyyp.addItem("1996");cboyyp.addItem("1997");cboyyp.addItem("1998");cboyyp.addItem("1999");cboyyp.addItem("2000");cboyyp.addItem("2001");cboyyp.addItem("2002");cboyyp.addItem("2003");cboyyp.addItem("2004");cboyyp.addItem("2005");cboyyp.addItem("2006");cboyyp.addItem("2007");cboyyp.addItem("2008");cboyyp.addItem("2009");cboyyp.addItem("2010");
cboyyp.addItem("2011"); cboyyp.addItem("2012");
cboddr=new JComboBox(); cboddr.addItem("Day");
cboddr.addItem("1");cboddr.addItem("2");cboddr.addItem("3");cboddr.addItem("4");cboddr.addItem("5");cboddr.addItem("6");cboddr.addItem("7");cboddr.addItem("8");cboddr.addItem("9");
18 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
cboddr.addItem("10");cboddr.addItem("11");cboddr.addItem("12");cboddr.addItem("13");cboddr.addItem("14");cboddr.addItem("15");cboddr.addItem("16");cboddr.addItem("17");cboddr.addItem("18");cboddr.addItem("19");cboddr.addItem("20");cboddr.addItem("21");cboddr.addItem("23");cboddr.addItem("24");cboddr.addItem("25");cboddr.addItem("26");cboddr.addItem("27");cboddr.addItem("28");cboddr.addItem("29");cboddr.addItem("30");cboddr.addItem("31");
cbommr=new JComboBox(); cbommr.addItem("Month");
cbommr.addItem("1");cbommr.addItem("2");cbommr.addItem("3");cbommr.addItem("4");cbommr.addItem("5");cbommr.addItem("6");cbommr.addItem("7");cbommr.addItem("8");cbommr.addItem("9");cbommr.addItem("10");cbommr.addItem("11");cbommr.addItem("12");
cboyyr =new JComboBox(); cboyyr.addItem("Year");
cboyyr.addItem("1980");cboyyr.addItem("1981");cboyyr.addItem("1982");cboyyr.addItem("1983");cboyyr.addItem("1984");cboyyr.addItem("1985");cboyyr.addItem("1986");cboyyr.addItem("1987");cboyyr.addItem("1988");cboyyr.addItem("1989");cboyyr.addItem("1990");
19 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
cboyyr.addItem("1991");cboyyr.addItem("1992");cboyyr.addItem("1993");cboyyr.addItem("1994");cboyyr.addItem("1995");cboyyr.addItem("1996");cboyyr.addItem("1997");cboyyr.addItem("1998");cboyyr.addItem("1999");cboyyr.addItem("2000");cboyyr.addItem("2001");cboyyr.addItem("2002");cboyyr.addItem("2003");cboyyr.addItem("2004");cboyyr.addItem("2005");cboyyr.addItem("2006");cboyyr.addItem("2007");cboyyr.addItem("2008");cboyyr.addItem("2009");cboyyr.addItem("2010");
cboyyr.addItem("2011"); cboyyr.addItem("2012"); lblpid.setBounds(new Rectangle(50,80,100,30)); txtid.setBounds(new Rectangle(200,80,100,30)); lblname.setBounds(new Rectangle(50,130,100,30)); txtname.setBounds(new Rectangle(200,130,100,30)); lblsecuritylevel.setBounds(new Rectangle(50,180,100,30)); cboseclevel.setBounds(new Rectangle(200,180,100,30)); lbldateofprison.setBounds(new Rectangle(50,230,100,30)); cboddp.setBounds(new Rectangle(200,230,50,30)); cbommp.setBounds(new Rectangle(260,230,50,30)); cboyyp.setBounds(new Rectangle(320,230,100,30)); lblrelease.setBounds(new Rectangle(50,280,100,30)); cboddr.setBounds(new Rectangle(200,280,50,30)); cbommr.setBounds(new Rectangle(260,280,50,30)); cboyyr.setBounds(new Rectangle(320,280,100,30)); //buttons
btnadd = new JButton("Add"); btnadd.setBounds(new Rectangle(20, 30 , 100 ,30 )); btndelete = new JButton("Delete"); btndelete.setBounds(new Rectangle(150, 30 , 90 ,30 )); btnsearch = new JButton("Search"); btnsearch.setBounds(new Rectangle(270, 30 , 90 ,30 ));
20 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
btnupdate = new JButton("Update"); btnupdate.setBounds(new Rectangle(390, 30 , 90 ,30 )); btndisplay = new JButton("Display"); btndisplay.setBounds(new Rectangle(510, 30 , 90 ,30 )); pnlPrisoner.add(lblpid); pnlPrisoner.add(txtid); pnlPrisoner.add(lblname); pnlPrisoner.add(txtname); pnlPrisoner.add(lblsecuritylevel); pnlPrisoner.add(cboseclevel); pnlPrisoner.add(lbldateofprison); pnlPrisoner.add(cboddp); pnlPrisoner.add(cbommp); pnlPrisoner.add(cboyyp); pnlPrisoner.add(lblrelease); pnlPrisoner.add(cboddr); pnlPrisoner.add(cbommr); pnlPrisoner.add(cboyyr); pnlPrisoner.add(btndisplay); pnlPrisoner.add(btnupdate); pnlPrisoner.add(btnsearch); pnlPrisoner.add(btndelete); pnlPrisoner.add(btnadd);
c.add(pnlPrisoner);
btndisplay.addActionListener(this); btnupdate.addActionListener(this); btnsearch.addActionListener(this); btndelete.addActionListener(this); btnadd.addActionListener(this);
pnlPrisoner.setVisible(true);
} public static void main(String[] args) {
Prisoner prison = new Prisoner ();prison.setSize(815,700);prison.setVisible(true);
21 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
}@SuppressWarnings("deprecation")@Overridepublic void actionPerformed(ActionEvent ev) {
if(ev.getSource()==btnadd){
int i=0; Calendar entrydate = Calendar.getInstance();
entrydate.set(Calendar.DATE, Integer.parseInt((String) cboddp.getSelectedItem()));
entrydate.set(Calendar.MONTH, Integer.parseInt((String) cbommp.getSelectedItem()));
entrydate.set(Calendar.YEAR, Integer.parseInt((String) cboyyp.getSelectedItem()));
Date dop = new Date(entrydate.getTimeInMillis());
Calendar dateofrelease = Calendar.getInstance();dateofrelease.set(Calendar.DATE, Integer.parseInt((String) cboddr
.getSelectedItem()));dateofrelease.set(Calendar.MONTH, Integer.parseInt((String) cbommr
.getSelectedItem()));dateofrelease.set(Calendar.YEAR, Integer.parseInt((String) cboyyr
.getSelectedItem()));Date dor = new Date(dateofrelease.getTimeInMillis());try {
Connection con=mydb.getDBConnection();String sql="INSERT INTO PRISON VALUES (?,?,?,?,?,?)";PreparedStatement ptmt=con.prepareStatement(sql);ptmt.setString(1, txtid.getText());ptmt.setString(2,txtname.getText() );ptmt.setString(3,(String)cboseclevel.getSelectedItem() );ptmt.setDate(4, dop);ptmt.setDate(5,dor );ptmt.setString(6,"Not released" );
i=ptmt.executeUpdate(); if(i>0) { JOptionPane.showMessageDialog(null, "Prisoner Inserted Successfully"); } else { JOptionPane.showMessageDialog(null, "Prisoner Not Inserted Successfully");
}
} catch (Exception e) {e.printStackTrace();
22 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
}}if(ev.getSource()==btnsearch){
Connection con=null; PreparedStatement ptmt; try { con=mydb.getDBConnection(); String sql="SELECT * FROM PRISON WHERE PID LIKE ?"; ptmt=con.prepareStatement(sql); ptmt.setString(1, txtid.getText()); ResultSet rs=ptmt.executeQuery(); while(rs.next()) { txtid.setText(rs.getString(1)); txtname.setText(rs.getString(2)); cboseclevel.setSelectedItem(rs.getString(3)); cboddp.setSelectedItem(rs.getDate(6).getDate()); cbommp.setSelectedItem(rs.getDate(6).getMonth()); cboyyp.setSelectedItem(rs.getDate(6).getYear()); cboddr.setSelectedItem(rs.getDate(7).getDate()); cbommr.setSelectedItem(rs.getDate(7).getMonth()); cboyyr.setSelectedItem(rs.getDate(7).getYear()); }
} catch (Exception e) {e.printStackTrace();
}}if(ev.getSource()==btndelete){
int i=0;
try {Connection con3=mydb.getDBConnection();String sql3 = "UPDATE PRISON SET Status=? WHERE PID=?";PreparedStatement ptmt3 = con3.prepareStatement(sql3);ptmt3.setString(1, "Dead");ptmt3.setString(2, txtid.getText());i = ptmt3.executeUpdate();
if(i>0)
23 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
{JOptionPane.showMessageDialog(null,"Prisoner Successfully
deletd");
}else{
JOptionPane.showMessageDialog(null,"Prisoner Successfully Not deletd");
}} catch (Exception e2) {
// TODO: handle exceptione2.printStackTrace();
}
}if(ev.getSource()==btnupdate){
ResultSet rs = null;int dd, mm, yy;int totaldaysLeft = 0;Calendar cd = Calendar.getInstance();Date dateOfRelese = null, dateDifference = null;
try {Connection con = mydb.getDBConnection();String sql = "SELECT * FROM PRISON WHERE PID LIKE ?";PreparedStatement ptmt = con.prepareStatement(sql);ptmt.setString(1, txtid.getText());rs = ptmt.executeQuery();
while (rs.next()) {dateOfRelese = rs.getDate(6);
}dd = dateOfRelese.getDate();mm = dateOfRelese.getMonth();yy = dateOfRelese.getYear();
con.close();ptmt.close();cd.set(yy, mm, dd);System.out.println(cd);dateDifference = new Date(cd.getTimeInMillis()
- Calendar.getInstance().getTimeInMillis());System.out.println(dateDifference);
totaldaysLeft = dateDifference.getDay();System.out.println("Total days left+"+totaldaysLeft);
24 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
if (totaldaysLeft > 7) {JOptionPane.showMessageDialog(null,
"The Prisoner Could not be released");} else {
int i = 0;try {
Connection con1 = mydb.getDBConnection();String sql3 = "UPDATE PRISON SET Status=? WHERE PID=?";PreparedStatement ptmt3 = con1.prepareStatement(sql3);ptmt3.setString(1, "Released");ptmt3.setString(2, txtid.getText());i = ptmt3.executeUpdate();if(i>0){
JOptionPane.showMessageDialog(null,"Prisoner Released Successfully");
}else {
JOptionPane.showMessageDialog(null,"Prisoner Couldnot Be Released");
}
} catch (Exception e2) {e2.printStackTrace();
}}
} catch (Exception e2) {e2.printStackTrace();
}
if (rs == null) {JOptionPane.showMessageDialog(null,
"Prisoner Couldnot Be Found");}
}if(ev.getSource()==btndisplay){
showpRecord ps=new showpRecord(); ps.setVisible(true); ps.setVisible(true);
25 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
}
}}
Save as : showpRecord
import java.awt.*;import javax.swing.*;import javax.swing.table.*;import javax.swing.event.*;import java.awt.event.*;import java.sql.*;import java.util.Vector;
public class showpRecord extends JFrame{
Container c;DefaultTableModel prisonerTablemodel;prisondbase db=new prisondbase();
Vector<String> prisonVector;JTable prisonTable;
showpRecord() { c=getContentPane(); setSize(1300,700); setTitle("Records For Prisoner ");
c.setBackground(Color.white);c.setLayout(null);setResizable(false);String pRecord[]={"Prisoner ID","Name"," Security Level ","Date Of Prison","Date Of
Release","Status"};prisonerTablemodel=new DefaultTableModel(pRecord,0);prisonTable=new JTable(prisonerTablemodel);JScrollPane jspPrisoner=new JScrollPane(prisonTable);
26 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
jspPrisoner.setSize(1150, 700);c.add(jspPrisoner);
try{
Connection con=db.getDBConnection();Statement st=con.createStatement();ResultSet rs=st.executeQuery("Select * from PRISON");while(rs.next()){
prisonVector=new Vector<String>(); prisonVector.add(rs.getString(1)); prisonVector.add(rs.getString(2)); prisonVector.add(rs.getString(3));
prisonVector.add(rs.getString(4));prisonVector.add(rs.getString(5));prisonVector.add(rs.getString(6));
prisonerTablemodel.addRow(prisonVector);}st.close();con.close();
} catch(Exception e){ System.out.println(e); }
setVisible(true);
setDefaultCloseOperation(3);
}}
Save as : showWardens.java
import java.awt.*;import javax.swing.*;import javax.swing.table.*;import javax.swing.event.*;import java.awt.event.*;import java.sql.*;import java.util.Vector;
public class showWardens extends JFrame {
27 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
Container c;DefaultTableModel WardenTablemodel;prisondbase db=new prisondbase();
Vector<String> WVector;JTable WardenTable;
showWardens() { c=getContentPane(); setSize(1000,700); setTitle("Records For Warden ");
c.setBackground(Color.white);c.setLayout(null);setResizable(false);String pRecord[]={"Warden ID"," Name "," Rank "};WardenTablemodel=new DefaultTableModel(pRecord,0);WardenTable=new JTable(WardenTablemodel);JScrollPane jspWarden=new JScrollPane(WardenTable);jspWarden.setSize(900, 700);c.add(jspWarden);
ResultSet rs=null;
try{
Connection con=db.getDBConnection();Statement st=con.createStatement(); rs=st.executeQuery("Select * from WARDEN");while(rs.next()){
WVector=new Vector<String>();
WVector.add(rs.getString(1)); WVector.add(rs.getString(2)); WVector.add(rs.getString(3));
WardenTablemodel.addRow(WVector);}
st.close();con.close();
} catch(Exception e){ System.out.println(e); }
28 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
setDefaultCloseOperation(3); }
}
4. Sample Output
Welcome Form: Prisoner Management System
29 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
Prisoner Form
Warden Form
30 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
5. Assumptions
Due to limited knowledge the following assumptions were made in the assignment:
validations on the textboxes have not been given, so it has been assumed that the user enters correct data
lesser class files could have been made
all the functionalities like add, delete, find etc are given on the same page
combo box has not been used to select warden id while adding a prisoner .
31 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
6. Conclusion
Finally completing this assignment I came to know more about Object oriented.
I have to implement some of the features of java to design Prisoner management
system. This assignment based on Prisoner management through database.
During the completion of the assignment, I have learned a many new things like
working with swing, action listeners. Now i can create Stand Alone
Application easily. I have become well aware of the following concepts of java:
ArraysClassesObjectsConstructorsInheritanceException HandlingAbstract classesInterfacePolymorphismLooping
32 Asia Pacific Institute of Information Technology
[ ] May 2, 2012
7.References
[1] http://www.java-examples.com/ [Accessed on : 1st April,12 ]
[2] http://en.wikipedia.org/wiki/Sequence_diagram [for sequence - definition : Accessed on : 26th April , 12 ]
[3] Dietel, H.M. & Dietel, P.J. (2001) Java: How to Program, Prentice Hall. (ISBN:
0130341517)
[4] http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/ [For Layout - Accessed on :
2nd April , 12 ]
33 Asia Pacific Institute of Information Technology