Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
BY
GAUTAM SONI
(ROLL NO. 09ELDIT017)
MR.BRIJ KISHORE
(ASSI. PROFESSOR)
Gautam Soni
Page 1
ACKNOWLEDGEMENT
Gratitude is the hardest of emotions to express and often one does find adequate words to convey that entire one feels. It has been my good fortune to come across many good-hearted people during my project activities. Although it is almost impossible to include the names of each one of them here. I gratefully thank them for their invaluable help and guidance in adding a fund of technical as well as general knowledge. I am immensely grateful to Mr. Jarnail Singh (Assist. Professor of Department of IT), for giving me constant guidance and valuable suggestions. This is possible with the help of Mrs. Reshu Grover(Assist. Professor of I.T. department) project guide, who guided me from till the end and was always there with his innovative ideas. I believe in teamwork and this sense cooperate me to work together and therefore I am thankful to my batch mates. At the conclusion I also express my deep sense of regards to my parents and all my well wishers who directly extended their help to this professional endeavor.
Gautam Soni B.Tech(I.T.) 7th sem.
Gautam Soni
Page 2
Gautam Soni
Page 3
Signature of supervisor/guide
(Assistant Professor)
Gautam Soni
Page 4
CONTENTS
Abstract Introduction Requirement Analysis System Analysis Design Analysis Implementation &Testing Source Code References
Gautam Soni
Page 5
ABSTRACT
Gautam Soni
Page 6
ABSTRACT Introduction: This project on library management system. This project majorly for manage the Database of a library .
Explanation: The main objective of this document is to illustrate the requirements of the project Library Management system. The document gives the d e t a i l e d d e s c r i p t i o n o f t h e b o t h functional and non functional requirements proposed by the client. The document is developed after a number of consultations with the client and considering the complete requirement specifications of the given Project. The final product of the team will be meeting the requirements of this document.
Gautam Soni
Page 7
REQUIREMENT ANALYSIS
REQUIREMENT ANALYSIS
Gautam Soni Page 8
For analysis of requirement for the software to be developed first of all we set
some guidelines and following those only we start analyzing in specific manner. The whole analysis work is divided in following activities:
1. 2. 3. 4. 5.
Problem Recognition Problem Evaluation and Solution Synthesis Modeling Creation Of Specification Review Of Analysis
Problem Recognition:
We deeply assess the use and technical feasibility of the software be developed
to
We meet the users and select all the persons who will be helping in specifying requirements and then understand their organizational bias. Then we define the technical environment into which the product or system was to be placed of the software. Then we identify the Domain Constraints i.e the specific environment needed for effective application. This helps us to limit the functionality and performance of the software. We choose the team meeting with users to elect one or more requirement.
Gautam Soni
Page 9
We observe all the data objects to be used by us and according to requirement. Then according to the objects and functions we have analyzed we now decided the flow of the information as per the requirements Then we define the software functions which we must make to obtain the flow and results with the data and achieve the projects objective. Now we analyze the behavior of the software in context with the software after defining all above tasks so as to fix the performance. Now we planned and analyzed the way which we must apply to have the asked type of user interface as per demand of the functions and data flow we have decided to use. Now we decide the requirements keeping in mind the system specifications. Also keeping in mind the information which we have to input to and output from the system so as to achieve the proper connectivity and transparency regarding the data.
Modeling:
The modeling is performed by designing the DFDs for all the possible states of the software.
Creation Of Specification:
The specifications were made as per the design analysis. It was confirmed that:
Is each requirement consistent with the product design? Is the requirement really necessary or just the add-on feature?
Page 10
Gautam Soni
Does any requirement conflicts with the other requirements? Is the requirement achievable in the specific technical environment?
Review Of Requirements:
In this stage we just review all the requirements listed by us and see arent we missing any one during our calculation and logic plannings. Here also we follow some basic guidelines:
Here we study the function and performance of computer based system and the constraints. The final statement of requirement was examined by the original sources. All the requirements related with a particular are listed in dependency traceability. The requirements which were testable were marked with tests to exercise the requirements later. It was made clear that the requirement is traceable to overall system/product objectives.
The requirements associated with the system performance, behavior, and operational characteristics were clearly stated.
SYSTEM
Gautam Soni Page 11
IMPLEMENTATION
SYSTEM IMPLEMENTATION
A system is an organized collection of interdependent components, which interact with each other and work together to achieve a common goal like in our project when system approach is applied to the Gautam Soni Page 12
development of information system solution, a multi step process or cycle emerges. This is called the System Development Life Cycle (SDLC),
Gautam Soni
Page 13
which
plays
an
important
role
in
analyzing
the
system.
Gautam Soni
Page 14
System Design
Survey, feasibility study and system analysis the system analyst carries out all these three things. In this the user requirement in translated into technical design and program design, which involves database design and program design. The project is carried out with great efforts and efficiently, keeping n mind all the needs and demands of the user, easy to understand by the user. All the above three steps are checked and maintained. Designing and caring of the system has taken with great responsibility. Thus a well-defined project has been designed to present and use.
Implementation
After all the above steps the system, which is designed, is to be converted into a program. Program can be written by using algo, pseudo codes and then a suitable language is selected. Thus, program is coded into a particular language which may be mysql, java, etc. our project has been made in java. It can be implemented in C, C++, java swings, applet but java is the most popular language, user friendly, and provides an excellent user interface. More than this java provides the facility to front end, which is capable of handling large database. Coding is part of implementation.
termination of the program. In this step we find out the reasons for these actions. This is called testing and after finding reasons we have to remove these errors to run the project accurately and efficiently. Like project, system can also have some errors files and records and explode into a much larger problem so effective testing should be done leading to save long term cost.
Documentation
Documentation is used to provide the help for the user to understand the project. Although the project has been made with such a great attention and keeping in mind of user understands so that the user can understand the project simply by working on it. But still then a detail description of the project has been given in case if the user has kind of working problem with the project. User manual has been made specially to help user to work on project. We had also provided some advices for future enhancement for project so that user can work on this project and make it more attractive and efficient.
Training
Training is the process by which different users can be made capable to work on project. An analysis of user training focuses on two factors that are user capabilities and system complexity. There is different range of users to give training, native to highly sophisticated and their way of learning is also different. User manual & help screens are easiest way to train the user.
Installation
Gautam Soni Page 16
In this procedure we have to install our project on users site. We provide an EXE of our project to the user so that user can use it but cannot change any backend record. For installing our project only setup file.
Maintenance
After doing all the above steps the maintenance is also necessary i.e. it is updated time to time. The output is good quality software. Maintenance means restoring something to its original condition. Maintenance may be repairing of processing & making changes due to some uncorrected problems or it may be changing the program to respond to users additional needs. Analysis is a detailed is a detailed study of the various operations performed by a system and their relationship within and outside of the system.
Gautam Soni
Page 17
DESIGN ANALYSIS
Gautam Soni Page 18
DESIGN ANALYSIS
Designing is the most important part of the software development lifecycle. It requires careful planning and logical thinking on the part of the software designer. Designing the software means how the various parts of the software are going to meet the user requirement and goals. It should be done with utmost care as a simple mistake or miscalculation at this stage can result in errors which can be compounded manifold as the development process moves up the development hierarchy. This compounded error can result in low performance, more processing time, and more coding and extra load. System Design attempts to accomplish the following: Improve productivity of analysts and programmers. Improve documentation and subsequent maintenance and
enhancements. Cut down drastically on cost over runs and delays. Improved communication among the users ,analysts, designers and programmers Standardize the approach to analysis and design Simplify design by segmentation
Gautam Soni
Page 19
Gautam Soni
Page 20
Before starting the program using JDBC ODBC bridge drivers, create tables in Microsoft Access according to requirement. Let its name be emp and fields ename, design, hiredate, deptno. Now lets create a DSN by name empdb, which we will use in the program based on JDBC ODBC drivers.
Adminlog
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Gautam Soni
AdminPage Cdate Changepassword DeleteAccount DeleteBook FirstPage FrmSplash Issue LibrarianPage Listbook ListMembers NewAccount NewBook Returnb UserPage
For admin page For current date For change password of user For delate a account For delate a book For welcome page For Splash For book issue For lib.login For book list For member list For create a new account For insert anew book For return a book For user login Page 21
17 18 19
WELCOME PAGE
Gautam Soni
Page 22
NEW ACCOUNT
Gautam Soni
Page 23
Admin login
Gautam Soni
Page 24
Staff login
user page
Gautam Soni
Page 25
book detail Dbconnection.java : This class provides cross-DBMS connectivity to a wide range of SQL databases. It also provides access to other tabular data sources such as spreadsheets or flat files. This class serves four things: Establish a connection with a database or access any tabular data source. Send SQL statements. Process the results. In this case, A Connection type of object conn denoting a connection to the database is created. A Statement type of object stmt is created using the Connection object i.e. conn. Use stmt to execute either update the database or send a query request. This class has four functions:
Gautam Soni Page 26
1) It connects to the database by openConnection() method. public Connection openConnection() { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection("jdbc:odbc:stu_prof_maintainance"); System.out.println("********connection opened*********"); return conn; } 2) It executes query : public ResultSet execSQLCommand (String qry, Connection conn) { ResultSet rs = null; Statement stmt = null; stmt = conn.createStatement(); rs = stmt.execute Query(qry); return rs; } 3 ) It updates query : public int updatetable (String qry, Connection conn) { ResultSet rs = null; Statement stmt = null;
Gautam Soni
Page 27
stmt = conn.createStatement(); rs = stmt.executeUpdate(qry); return retvalue; } 4) It closes the Connection : public void closeConnection(Connection conn) { conn.close(); stmt.close(); }
BACK END
The back end, which is the tool used for the designing of the database required in the application was chosen to be Microsoft Access, which provides powerful tools for managing and analyzing. The various tables used are1. adminfo- This table contain administrator name and administrator password which are used to login through login window by administrator.
Gautam Soni
Page 28
2. personaldata - This table personal information of student profile like name, password and e-mail, percentage.
3 Installation:
The component comprises of several Java Classes, some image files (Java Archive). To start using this component, - we will save the java files in bin folder of jdk1.5. - Provide necessary database connection details and information about the URLs. - Install Microsoft-Access in system. - And save the various tables used in the project. Data Flow Diagrams (DFD)
Gautam Soni
Page 31
Gautam Soni
Page 32
SOURCE CODE
Gautam Soni
Page 33
import java.awt.event.*; import java.awt.*; import javax.swing.*; public class FirstPage extends javax.swing.JFrame { /** Creates new form FirstPage */ public FirstPage() { initComponents(); } JPanel Panel1; JDesktopPane Desk1 = new JDesktopPane(); JLabel StatusLabel = new JLabel("Copyright 2012 gautam soni. All Rights Reserved., JLabel.CENTER); JLabel BusinessTitleLabel = new JLabel(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); FrmSplash FormSplash = new FrmSplash(); //--End variable the contains forms Thread ThFormSplash = new Thread(FormSplash); //End the form container variable /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code "> private void initComponents() { loadSplashScreen(); //We will dispose now the FormSplash because it is now useless
Gautam Soni
Page 34
FormSplash.dispose(); jLabel1 = new javax.swing.JLabel(); datte = new javax.swing.JLabel(); dattee = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(new ImageIcon("wclogo_niit.gif"));
getContentPane().setLayout(null); setForeground(new java.awt.Color(0, 153, 204)); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("WELCOME"); datte.setFont(new java.awt.Font("Tahoma", 3, 24)); datte.setForeground(new java.awt.Color(102, 102, 0)); datte.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); //datte.setText(""); datte.setText(dat); getContentPane().add(datte); datte.setBounds(540, 40, 250, 70); dattee.setFont(new java.awt.Font("Tahoma", 3, 24)); dattee.setForeground(new java.awt.Color(0, 0, 0)); dattee.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); dattee.setText("DATE :="); getContentPane().add(dattee); dattee.setBounds(370, 40, 200, 70); jLabel1.setFont(new java.awt.Font("Tahoma", 3, 48)); jLabel1.setForeground(new java.awt.Color(0, 0, 0));
Gautam Soni
Page 35
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("CENTERAL LIBRARY "); getContentPane().add(jLabel1); jLabel1.setBounds(190, 195, 500, 110); jLabel2.setFont(new java.awt.Font("Tahoma", 3, 36)); jLabel2.setForeground(new java.awt.Color(0, 0, 0)); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("WELCOME TO THE"); getContentPane().add(jLabel2); jLabel2.setBounds(220, 140, 430, 70); jLabel3.setFont(new java.awt.Font("Tahoma", 3, 48)); jLabel3.setForeground(new java.awt.Color(0, 0, 0)); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setText("NIIT "); getContentPane().add(jLabel3); jLabel3.setBounds(210, 280, 410, 110);
jButton2.setBorder(javax.swing.BorderFactory.createEtchedBorder()); getContentPane().add(jButton2); jButton2.setBounds(10, 10, 87, 99); jButton1.setFont(new java.awt.Font("Tahoma", 1, 24)); jButton1.setForeground(new java.awt.Color(102, 102, 0)); jButton1.setText("ENTER"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { setVisible(false); //dispose(); LogPage llp = new LogPage();
Gautam Soni
Page 36
} });
getContentPane().add(jButton1); jButton1.setBounds(500, 440, 210, 50); pack(); setSize(800, 600); setLocation(50, 50); setVisible(true);
}// </editor-fold> protected void loadSplashScreen() { //Start the thread ThFormSplash.start(); while (!FormSplash.isShowing()) { try { Thread.sleep(3000); } catch (InterruptedException e) { } } } /** * @param args the command line arguments */ public static void main(String args[]) {
Gautam Soni
Page 37
cdate dd = new cdate(); dd.ccdate(); dat = dd.todaydate.toString(); // dat=(String)dd.todaydate(); System.out.println(dat); /* try { javax.swing.UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel"); } catch (Exception e) { System.out.println("Error Loading Theme:" + e.toString()); //If Failed to load the liquid them then load my own XPStyleTheme MetalTheme myXPStyleTheme = new XPStyleTheme(); MetalLookAndFeel.setCurrentTheme(myXPStyleTheme); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception err) { System.out.println("Error loading myXPStyleTheme:" + err.toString()); }*/
FirstPage fp = new FirstPage(); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel datte; private javax.swing.JLabel dattee; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JButton jButton2; private static String dat; // End of variables declaration
Gautam Soni
Page 38
import java.*; import java.util.*; import java.io.*; public class cdate{ public static String days[]={" ","sun","mon","tue","wed","thur","fri","sat"}; public static String month[]={"jan" ,"feb","march","april","may","june","july","aug","sep","oct","nov","dec"}; public static StringBuffer todaydate=new StringBuffer(); public static StringBuffer returndate=new StringBuffer(); public static StringBuffer todaydatee=new StringBuffer();; public static StringBuffer returndatee=new StringBuffer();; public static void main(String[] args){ cdate dddd=new cdate(); dddd.ccdate(); System.out.println(todaydate); System.out.println(todaydatee); System.out.println(returndate); System.out.println(returndatee); }
Gautam Soni
Page 39
int valofmonth=g.get(Calendar.MONTH); String mon=month[valofmonth]; int valofyear=g.get(Calendar.YEAR); //System.out.println(valofday); //System.out.println(valofmonth); //System.out.println(valofyear); todaydate.append(daay +"-"); todaydate.append(todate); todaydate.append("-"+mon); todaydate.append("-"+valofyear); todaydatee.append(todate); todaydatee.append("-"+valofmonth); todaydatee.append("-"+valofyear); //System.out.println(todaydatee.toString()); g.add(Calendar.DAY_OF_MONTH,21); int val=g.get(Calendar.DAY_OF_MONTH); int valmonth=g.get(Calendar.MONTH); int valyear=g.get(Calendar.YEAR); //System.out.println(val); //System.out.println(valmonth); //System.out.println(valyear);
Gautam Soni
Page 40
}catch(Exception e){e.printStackTrace();} }
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; import javax.swing.table.*; public class DeleteAccount extends javax.swing.JFrame { /** Creates new form NewAccount */ public DeleteAccount() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */
Gautam Soni
Page 41
// <editor-fold defaultstate="collapsed" desc=" Generated Code "> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); accountno = new javax.swing.JTextField(); delete = new javax.swing.JButton(); finish = new javax.swing.JButton(); getContentPane().setLayout(null); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("DETAIL OF NEW USER"); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); jLabel1.setForeground(new java.awt.Color(102, 0, 0)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel1.setText("ACCOUNT NO:"); getContentPane().add(jLabel1); jLabel1.setBounds(60, 70, 150, 20); jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel6.setText("DELETE ACCOUNT"); getContentPane().add(jLabel6); jLabel6.setBounds(130, 20, 300, 20); accountno.setFont(new java.awt.Font("Tahoma", 0, 14)); getContentPane().add(accountno); accountno.setBounds(250, 70, 140, 20); delete.setText("DELETE"); delete.setToolTipText("cklick to delete account"); delete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) {
Gautam Soni
Page 42
if (accountno.getText().equals("")) { JOptionPane.showMessageDialog((Component) null, "Plese Enter \n the account no ", "Login Error", JOptionPane.INFORMATION_MESSAGE); } else { deluserdetails(); }
} }); getContentPane().add(delete); delete.setBounds(200, 120, 80, 30); finish.setText("RETURN"); finish.setToolTipText("click to return"); finish.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { setVisible(false); //AdminPage app=new AdminPage(); } }); getContentPane().add(finish); finish.setBounds(310, 120, 80, 30); pack(); setSize(500, 225); setVisible(true); setLocation(200, 200); }// </editor-fold> /**
Gautam Soni
Page 43
* @param args the command line arguments */ public static void main(String args[]) { DeleteAccount db = new DeleteAccount(); } // Variables declaration - do not modify private javax.swing.JTextField accountno; private javax.swing.JButton delete; private javax.swing.JButton finish; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel6; // End of variables declaration void deluserdetails() { Connection con = null; String url = "jdbc:odbc:NiitLibrary"; Statement st = null; try { String delusr = accountno.getText(); delusr = delusr.trim(); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection(url); st = con.createStatement();
int ii = st.executeUpdate("delete * From usernpasswd Where UserId='" + delusr + "'"); int iii = st.executeUpdate("delete * From userdata Where useridno='" + delusr + "'");
Gautam Soni
Page 44
if (ii > 0) { accountno.setText(""); JOptionPane.showMessageDialog((Component) null, "USER ACCOUNT" + delusr + "\n DELETED", "SUCCESS", JOptionPane.INFORMATION_MESSAGE); } else { //accountno.setText(""); JOptionPane.showMessageDialog((Component) null, "THE USER DOESn't exist", "Error", JOptionPane.ERROR_MESSAGE); } } catch (SQLException ex) { System.out.println("Unable to access the database"); } catch (ClassNotFoundException ex) { System.out.println("Class not found"); } catch (Exception ex) { System.out.println("Exception raised is:" + ex); } finally { con = null; } } }
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; import javax.swing.table.*; public class LibrarianPage extends javax.swing.JFrame { /** Creates new form AdminPage */ public LibrarianPage() { heading.setBounds(380, 20, 310, 30);
Gautam Soni
Page 45
heading1.setFont(new java.awt.Font("Tahoma", 3, 14)); heading1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); heading1.setText(" ISSUE BOOK =>"); getContentPane().add(heading1); heading1.setBounds(110, 160, 210, 30); heading3.setFont(new java.awt.Font("Tahoma", 3, 14)); heading3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); heading3.setText("DELETE BOOK DETAIL =>"); getContentPane().add(heading3); heading3.setBounds(120, 380, 210, 30); heading5.setFont(new java.awt.Font("Tahoma", 3, 14)); heading5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); heading5.setText("RESERVE BOOK getContentPane().add(heading5); heading5.setBounds(130, 270, 210, 30); issuebook.setText("ISSUE"); issuebook.setToolTipText("Click to create new account"); issuebook.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { issue iss=new issue(); } }); getContentPane().add(issuebook); issuebook.setBounds(380, 160, 120, 30); addbooks.setText("ADD NEW BOOK"); addbooks.setToolTipText("add new boooks"); addbooks.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { =>");
Gautam Soni
Page 46
//setVisible(false); NewBook nb=new NewBook(); } }); getContentPane().add(addbooks); addbooks.setBounds(390, 330, 120, 30); deletebooks.setText("DELETE BOOK"); deletebooks.setToolTipText("Delete book"); deletebooks.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { //setVisible(false); DeleteBook db=new DeleteBook(); } }); getContentPane().add(deletebooks); deletebooks.setBounds(390, 380, 120, 30); reserve.setText("RESERVE"); reserve.setToolTipText("reserve book"); reserve.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { reservebook rb=new reservebook(); } }); reserve.setFocusPainted(false); getContentPane().add(reserve); reserve.setBounds(380, 270, 120, 30);
Gautam Soni
Page 47
logout.setFont(new java.awt.Font("Tahoma", 1, 14)); logout.setText("LOG OUT"); logout.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { setVisible(false); LogPage lp=new LogPage(); } }); getContentPane().add(logout); logout.setBounds(550, 450, 100, 50); heading4.setFont(new java.awt.Font("Tahoma", 3, 18)); heading4.setForeground(new java.awt.Color(0, 102, 102)); heading4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); heading4.setText("STAFF PAGE"); getContentPane().add(heading4); heading4.setBounds(30, 20, 310, 30); heading6.setFont(new java.awt.Font("Tahoma", 3, 14)); heading6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); heading6.setText("ADD NEW BOOKS =>"); getContentPane().add(heading6); heading6.setBounds(120, 330, 210, 30); heading7.setFont(new java.awt.Font("Tahoma", 3, 14)); heading7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); heading7.setText("RETURN BOOK =>"); getContentPane().add(heading7); heading7.setBounds(120, 220, 210, 30); returnbook.setText("RETURN"); returnbook.setToolTipText("click to return book");
Gautam Soni
Page 48
returnbook.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { returnb rrr=new returnb(); } }); getContentPane().add(returnbook); returnbook.setBounds(380, 220, 120, 30); pack(); setSize(800,600); setLocation(50,50); setVisible(true); }// </editor-fold> /** * @param args the command line arguments */ public static void main(String args[]) { LibrarianPage lp=new LibrarianPage(); } // Variables declaration - do not modify private javax.swing.JButton addbooks; private javax.swing.JButton deletebooks; private javax.swing.JLabel heading; private javax.swing.JLabel heading1; private javax.swing.JLabel heading3; private javax.swing.JLabel heading4; private javax.swing.JLabel heading5; private javax.swing.JLabel heading6; private javax.swing.JLabel heading7; private javax.swing.JButton issuebook;
Gautam Soni
Page 49
private javax.swing.JButton logout; private javax.swing.JButton reserve; private javax.swing.JButton returnbook; // End of variables declaration } import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class SearchBook extends JFrame implements ActionListener { private JPanel pBook = new JPanel (); private JLabel lbSearch; private JRadioButton rb1,rb2,rb3,rb4; private JTextField txtSearch; private JButton btnFind, btnCancel; private int flag=0; private Statement st; private String bname,bauthor,bcat,search; private int bref,bmid,bid,rows=0; private JTable table; private JScrollPane jsp; private Object data1[][]; private Container c; public SearchBook () {
Gautam Soni
Page 50
lbSearch = new JLabel ("Search Field"); lbSearch.setForeground (Color.black); lbSearch.setBounds (15, 15, 100, 20); txtSearch = new JTextField (); txtSearch.setBounds (120, 15, 175, 25);
btnFind = new JButton ("Find Book"); btnFind.setBounds (25, 175, 125, 25); btnFind.addActionListener (this); btnCancel = new JButton ("Cancel"); btnCancel.setBounds (165, 175, 125, 25); btnCancel.addActionListener (this); rb1=new JRadioButton("By Title"); rb1.addActionListener(this); rb1.setBounds (15, 45, 100, 20); rb2=new JRadioButton("By Author"); rb2.addActionListener(this); rb2.setBounds (15, 75, 100, 20); rb3=new JRadioButton("By Category"); rb3.addActionListener(this); rb3.setBounds (15, 105, 100, 20); rb4=new JRadioButton("By id"); rb4.addActionListener(this); rb4.setBounds(15,135,100,20); pBook.setLayout (null); pBook.add(lbSearch); pBook.add(txtSearch); pBook.add(btnFind);
Gautam Soni
Page 51
pBook.add(btnCancel); ButtonGroup bg=new ButtonGroup(); bg.add(rb1); bg.add(rb2); bg.add(rb3); bg.add(rb4); pBook.add(rb1); pBook.add(rb2); pBook.add(rb3); pBook.add(rb4); rb1.setSelected(true); getContentPane().add (pBook, BorderLayout.CENTER); c=getContentPane(); /*try { //Connection con=null; // Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); //String loc = "jdbc:odbc:niitLibrary"; //con = DriverManager.getConnection (loc); } catch (SQLException sqlex) { User a Message. JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form."); dispose (); }*/ //Closing the Form. //If Problem then Show the
Gautam Soni
Page 52
public void actionPerformed (ActionEvent ae) { Object obj = ae.getSource(); if (obj == btnFind) { //If Find Button Pressed.
if (txtSearch.getText().equals ("")) { JOptionPane.showMessageDialog (this, "Search Field not Provided."); txtSearch.requestFocus (); } else { String bname1,bauthor1,bcat1; int num; boolean found = false; Confirm the Book's Id Existance. Connection con=null; String url="jdbc:odbc:NiitLibrary"; Statement st=null; try { //SELECT Query to Retrieved the Record. //To
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection(url); st = con.createStatement(); String q,bavl,bisr; num=st.executeUpdate("Delete * from bksearch"); ResultSet rs = st.executeQuery ("SELECT * FROM bk "); //Executing the Query.
Gautam Soni
Page 53
while(rs.next()) { bname=rs.getString(2); bauthor=rs.getString("bauther"); bcat=rs.getString("bcat"); bmid=rs.getInt("Statuss"); if(bmid==0) bavl="Available"; else bavl="Issued:"+ bmid; bid=rs.getInt("bookid"); if(flag==0) { bname1=bname.toLowerCase(); if(bname1.equals(search)|| (bname1.indexOf(search)!=-1)) { System.out.println("Came Here2"); num=st.executeUpdate("insert into bksearch values("+bid+", '"+bname+"','"+bcat+"','"+bauthor+"' , '"+bavl+"')"); rows++; found=true; System.out.println("bookname"); } }
Gautam Soni
Page 54
else if(flag==1) { bauthor1=bauthor.toLowerCase(); if(bauthor1.equals(search)|| (bauthor1.indexOf(search)!=-1)) { num=st.executeUpdate("insert into bksearch values("+bid+", '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"')"); rows++; found=true; System.out.println("auther"); } } else if(flag==2) { bcat1=bcat.toLowerCase(); if(bcat1.equals(search)|| (bcat1.indexOf(search)!=-1)) { num=st.executeUpdate("insert into bksearch values("+bid+", '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"')"); rows++; found=true; System.out.println("catagory"); } } else if(flag==3) { if(bid==Integer.parseInt(txtSearch.getText())) { rows++; num=st.executeUpdate("insert into bksearch values("+bid+", '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"')");
Gautam Soni
Page 55
found=true; System.out.println("id"); } } }
} catch(SQLException ex) { if (found == false) { JOptionPane.showMessageDialog "Record not Found."); } } catch(ClassNotFoundException ex) { System.out.println("Class not found"); } catch(Exception ex) { System.out.println("Exception raised is:"+ex); } if(found==true){ try{ data1=new Object[rows][5]; Object[] Name","Category","Author","Availability"}; ResultSet rs=st.executeQuery("Select * from bksearch"); Colheads={"Book Id","Book (this,
Gautam Soni
Page 56
for(int i1=0;i1<rows;i1++) { rs.next(); for(int j1=0;j1<5;j1++) { data1[i1][j1]=rs.getString(j1+1); } } rs.close(); st.close(); con.close(); table=new JTable(data1,Colheads); int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; System.out.println("hai we came here"); jsp=new JScrollPane(table,v,h); TableDisp td=new TableDisp(table);
} catch(Exception sqlex) { if (found == false) { JOptionPane.showMessageDialog "Some prob Found."); } } } } } if (obj == btnCancel) { //If Cancel Button Pressed Unload the From. (this,
Gautam Soni
Page 57
setVisible (false); dispose(); } if(obj==rb1) { flag=0; } if(obj==rb2) { flag=1; } if(obj==rb3) { flag=2; } if(obj==rb4) { flag=3; } } public static void main(String[] args){ SearchBook sbb=new SearchBook();
Gautam Soni
Page 58
public class ChatServer { public static void main(String[] args) { ChatServer cs = new ChatServer(); cs.go(); } public final static int DEFAULT_PORT = 2000; public final static int DEFAULT_MAX_BACKLOG = 5; public final static int DEFAULT_MAX_CONNECTIONS = 20; public final static String DEFAULT_HOST_FILE = "hosts.txt"; public final static String DEFAULT_SOUND_FILE = "file:gong.au"; public final static String MAGIC = "Yippy Skippy"; private String magic = MAGIC; private int port = DEFAULT_PORT; private int backlog = DEFAULT_MAX_BACKLOG; private int numConnections = 0; private int maxConnections = DEFAULT_MAX_CONNECTIONS; private String hostfile = DEFAULT_HOST_FILE; private String soundfile = DEFAULT_SOUND_FILE; private List<Connection> connections = null; private AudioClip connectSound = null; private Map<String,String> hostToStudentMap = null; // // Methods for the Connection class // } catch (IOException e) { System.out.println("Error starting server: Could not open port "+port); e.printStackTrace(); System.exit(-1);
Gautam Soni
Page 59
} System.out.println ("Started server on port "+port); // Run the listen/accept loop forever while (true) { try { // Wait here and listen for a connection communicationSocket = serverSocket.accept(); handleConnection(communicationSocket); } catch (Exception e) { System.out.println("Unable to spawn child socket."); e.printStackTrace(); } } } private synchronized void handleConnection(Socket connection) { while (numConnections == maxConnections) { try { wait(); } catch(Exception e) { e.printStackTrace(); } } numConnections++; Connection con = new Connection(this, connection); Thread t = new Thread(con); t.start(); connections.add(con); }} import java.io.*; import java.net.*; class Connection implements Runnable {
Gautam Soni
Page 60
ChatServer server = null; private Socket communicationSocket = null; private OutputStreamWriter out = null; private BufferedReader in = null; public Connection(ChatServer server, Socket s) { this.server = server; this.communicationSocket = s; } public void sendMessage(String message) { try { out.write(message); out.flush(); } catch(Exception e) { e.printStackTrace(); } } public void run() { OutputStream socketOutput = null; InputStream socketInput = null; String magic = server.getMagicPassphrase(); try { socketOutput = communicationSocket.getOutputStream(); out = new OutputStreamWriter(socketOutput); socketInput = communicationSocket.getInputStream(); in = new BufferedReader(new InputStreamReader(socketInput));
Gautam Soni
Page 61
String welcome = "Connection made from host: "+hostname+"\nEverybody say hello"; String student = server.getStudentName(hostname); if (student != null) welcome += " to "+student; welcome+="!\n"; server.sendToAllClients(welcome); System.out.println("Connection made "+student+"@"+hostname); sendMessage("Welcome "+student+" the passphrase is "+magic+"\n"); String input = null; while ((input = in.readLine()) != null) { if (input.indexOf(magic) != -1) { server.playMagicSound(); sendMessage("Congratulations "+student+" you sent the passphrase!\n"); System.out.println(student+" sent the passphrase!"); } else { server.sendToAllClients(input+"\n"); } } } catch(Exception e) { e.printStackTrace(System.err); } finally { try { if (in != null) in.close(); if (out != null) out.close(); communicationSocket.close(); } catch(Exception e) { e.printStackTrace(); } server.closeConnection(this); }
SYSTEM SUMMARY:
OS Name Version Microsoft Windows 7 Home Basic 6.1.7601 Service Pack 1 Build 7601 Page 62
Gautam Soni
Other OS Description Not Available OS Manufacturer Microsoft Corporation System Name GAUTAM-HP System Manufacturer Hewlett-Packard System Model HP G42 Notebook PC System Type x64-based PC Processor Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz, 2399 Mhz, 2 Core(s), 4 Logical Processor(s) BIOS Version/Date SMBIOS Version Windows Directory System Directory Locale India Hardware Abstraction Layer Version = "6.1.7601.17514" User Name Time Zone gautam-HP\gautam India Standard Time 3.00 GB 2.86 GB Hewlett-Packard F.32, 23-11-2010 2.6 C:\Windows C:\Windows\system32
Available Physical Memory 1.63 GB Total Virtual Memory 5.73 GB Available Virtual Memory Page File Space Page File C:\pagefile.sys 3.66 GB 2.86 GB
Gautam Soni
Page 63
REFRENCES
1. The Complete Reference JAVA- Herbert Schildt 2. JDBC OReilly 3. Java Swing Eckstein, Loy, Wood; OReilly 4. Database management System -Korth
Gautam Soni
Page 64