library management system

135
LIBRARY MANAGEMENT SYSTEM Table of contents Page No. 1 Introduction 1.1 Problem Definition 3 1.2 Objective & Scope 3 1.3 Proposed System 5 1.4 Assumptions & Constraints 6 1.5 System Requirements 7 2 Software Requirement Specification[SRS] & Design 2.1 Introduction Purpose 8 System overview 8 2.2 Overall description Product perspective 10 Product functions Sumeet Dhende (2012450009) Jeet Dholakia (2012450010)Page 1

Upload: ronak-bafna

Post on 25-Nov-2015

223 views

Category:

Documents


1 download

DESCRIPTION

Library management system

TRANSCRIPT

LIBRARY MANAGEMENT SYSTEM

Table of contents Page No.

1 Introduction1.1 Problem Definition 31.2 Objective & Scope 31.3 Proposed System 5 1.4 Assumptions & Constraints 6 1.5 System Requirements 7

2 Software Requirement Specification[SRS] & Design 2.1 IntroductionPurpose 8 System overview 8 2.2 Overall descriptionProduct perspective 10Product functions 10User characteristics 10Constraints, assumptions and dependencies 11

3 Specific requirements3.1 Interface requirements 123.2 Functional requirements 123.3 Performance requirements 133.4 Design constraints 133.5 Database Schema 143.6 Software System attributes 163.7 Detailed Life Cycle of the project 16

4 Project Implementation4.1 Work Break down Structure 194.2 Gantt Chart 204.3 Pert Chart 224.4 Code with reference to design 234.5 Snapshot of UI & Reports 96

5 Future Enhancements 102

6 Limitations 103

7 Conclusion 104

8 Bibliographies 105

CHAPTER 1INTRODUCTION1.1 Problem DefinitiontO DEVELOP A LIBRARY MANAGEMENT SYSTEM.Library Management System can be used by education institutes to maintain the records of books easily. Achieving this objective is difficult using manual system as the information is scattered, can be redundant and collecting relevant information may be very time consuming. All these problems are solved using this project.As there are many books present in library and also there are various books issued by librarians to the members. It is very difficult to maintain huge catalogue within reasonable space constraints manually and to maintain the same is very time and space consuming process. If we want complete information of available books or issued books at any given point of time it is difficult to get it. Although manual system can handle but there are some flaws in this system: Data Redundancy. Lot Of Paperwork Involved. Time Consuming Process. Risk of Data Loss etc1.2 Objective & ScopeObjective The system is a standalone system. The admin can issue and renew the book. The system empowers the administrator to issue fines on books that are overdue. The system can maintain the data about the books. The system can categorize the books according to the courses.ScopeWithout a Library management System, managing and maintaining the details of the book is a tedious job for any college. Library management system will store all the details of the books including their category, availability and also maintains the details about the students to whom the books are issued. Login module: Login module will help in authentication of user accounts. Users who have valid login id and password can only login into their respective accounts Search module: Suppose there are hundreds of students and from this we have to search a particular student and we know the name of the student .In manual system it is a tedious task though we know the name of the student, but using this module we can easily search the student by specifying the name of the student in the search criteria. Thus this module will help the administrator in searching the student with various criteria easily. Addition of Books: This module helps to add the books details according to category wise. Deletion of Books: This module provides the admin option to delete the existing books from the given category and the admin can delete the already existing books from the database. Addition of Student Details: This module helps to add and maintained the details about the students to whom the books have been issued, the details of the students are categories according to their courses. Fine Module: If the student doesnt returns the books on the given due date than this module helps to imply fine on that particular student Admin id Admin password Book Details Book Issued Date Book Return Date Student idExisting SystemAccording to existing manual system it very tedious and time consuming work to maintain consistency of books record. There are large numbers of students who regularly take and returns books and to maintain this large data manually. It takes lot of paper work and consumes more time and place. There is also a risk of data loss because of degradation of registers, papers misplace from register etc.Apart from this there is risk of duplication of data and manipulation of data without prior authority and maintaining that record and keep them safe for long period of time is very difficult. On other hand data of particular books and students whose data is scattered in different registers and very hard for anyone to gather data of particular student or books.1.3 Proposed SystemLibrary Management System can be used by education institutes to maintain the records of books according to their categories and to whom they are issued easily. Achieving this objective is difficult using a manual system as the information is scattered, can be redundant and collecting relevant information may be very time consuming. All these problems are solved using this project.

1.4 Assumptions & Constraints

Assumptions:

All the data entered will be correct and up to date.

Administrator is created in the system already.

This software package is developed using JAVA as front end, MS SQL as the back end which is supported by Microsoft Windows XP.

The code should be free with compilation errors or system errors. The product must have an interface which is simple enough to understand.

Constraints:

Any update regarding the availability of books, return of books, fine imposed on the students, issued date and due date are to be recorded to have updated and correct values.

Login and password is used for identification of admin.

1.5 System Requirements

Operating Systems: Microsoft Windows or Linux

Technologies Used:

Front End: JAVA RDBMS(Back end): MySQLSoftware Requirements: Netbeans IDE 7.0 Microsoft Windows or Linux. XAMPP Server with MySQL.Hardware Requirements: Intel Pentium IV processor or equivalent or higher 512 MB Ram or Higher 20 GB HDD or Higher Network Connectivity

CHAPTER 2SOFTWARE REQUIREMENT SPECIFICATIONS2.1 Introduction:Purpose:An SRS establishes the basis for the agreement between the client and the developer on what the software product will do. SRS provides a reference for validation of the final product. A high quality SRS is a prerequisite to high-quality software. A high quality SRS reduces the development cost.System Overview:The basic issues an SRS must address are: Functional Requirements Performance Requirements Design constraints imposed on implementation External interface Requirements

STOPRemove BooksSTARTLoginList Available BooksList All BooksAdd BooksReserveLoanSearchEdit BooksList Borrowed BooksMember InfoRemove MembersEdit MembersMembersBooksReserve a BookIssued Book DetailsReturn A BookBorrow a BookList All MembersAdd Members

2.2 Overall DescriptionProduct Perspective:The Student Information System is a replacement for traditional method of saving documents in paper format or in electronic format where conventional methods are used. The SIS is an advanced system to store, edit & manage in a secure mannerProduct Functions:Administrator: Login and logout to/from the account Add, view, modify, search and delete all the details of Books. Delete book from particular category. Add, view, edit, search and remove Category. Can view the due dates of the issued books. Can view the details related to books returned.User Characteristics:Users of this system are librarian of the college who is administrator who maintains the system. The librarian should have basic knowledge of computers and internet browsing. The administrator should have some more knowledge, much about the system modules. So the admin can rectify problems caused due to catastrophic failures like hardware or power failures. Friendly graphical user interface and documents with the system will be sufficient to educate a user on how to use the system effectively, without any problems or difficulties. General users with basic computer skills can use this software. Knowledgeable User Novice User Expert User

Constraints, Assumptions and Dependencies:The success of the system depends on: Hardware specifications of the server machine Ratio of number of user machines to server machines Along with the system, the following third party programs will be required for the best experience: Netbeans IDE. MySQL.

CHAPTER 3SPECIFIC REQUIREMENTS AND PROJECT ANALYSIS AND DESIGN3.1 Interface Requirements:User Interface: A software provides the front-end, i.e. the user interface. Login Admin Add Edit, Remove and Search Borrowers. Add Edit, Remove and Search Borrowed books. Add Edit, Remove and Search Books. Search and Preview due dates of the Books. Search and Preview Returned dates of the Books. Add Edit, Remove and Search Categories. Add and Remove Yearly Records. Add Edit, Remove and Search Sections.

3.2 Functional Requirements: Login:An administrator can login to the system and access the different types of functionalities.Search: Admin can search for the various types of functionality in the software like search of books, any particular books category wise, due date of the book, issue date of the book, borrowers.Addition of Records: Admin can add different types of books, borrowers, categories and different type of records.Deletion of Records: Admin has rights to delete different types of records like books, borrowers, categories and other records.Editing: Admin can edit the details related to books, category of books, borrowers, due date and returned date.3.3 Performance requirements:Time: The library management system is to be developed in 30 days. The deadline should not exceed beyond 15 days. The tasks should divided in such a way that the project can be completed in minimum possible time.Cost:To develop this project all open source software are used. Both JAVA and MySQL are open source and hence there is no cost of the software used. Hardware requirements are also basic and hence there is no need to extra investment on hardware. Quality:The quality of the software is to be maintained. although the time is less but the task should be manage in such way that maximum possible functionalities are implemented. 3.4 Design constraints:The development of the system can be done using any basic text editor and using XAMP's developers interface. The system can be used on any operating system with a web browser.3.5 Database Schema:BooksColumnTypeCONSTRAINT

BookIDintegerPrimary Key

Subject varchar(20)Not Null

Titlevarchar(20)Not Null

Authorvarchar(20)Not Null

Publisher Varchar(20)Not Null

CopyrightintegerNot Null

EditionintegerNot Null

PagesintegerNot Null

ISBNVarchar(50)Not Null

NumberOfBooksIntegerNot Null

NumberOfAvailabeBooksIntegerNot Null

NumberOfBorrowedBooksintegerNot Null

LibraryVarchar(10)Not Null

AvailableintegerNot Null

ShelfNointegerNot Null

Borrow

ColumnTypeCONSTRAINT

BookIDintegerForeign Key

MemberIDvarchar(20)Foreign Key

DayOfBorrowedvarchar(20)Not Null

DayOfReturnvarchar(20)Not Null

Members

ColumnTypeCONSTRAINT

MemberIDintegerPrimary Key

ID integerNot Null

Passwordvarchar(20)Not Null

NAMEvarchar(20)Not Null

EMAILvarchar(20)

Majorvarchar(20)Not Null

NumberOfBooksintegerNot Null

MonyintegerNot Null

ExpireddatetimeNot Null

3.6 Software System Attributes:The system was developed considering the following attributes: Security Efficient resource utilization Ease in uploading and sharing documents Response time Efficient and consistent logic Maintainability 3.7 Detailed life Cycle of the Project:

The general methodology in developing a system is involved in different phases which describe the systems life cycle model for developing software project. The concept includes not only forward motion but also have the possibility to return that is cycle back to an activity previously completed. This cycle back or feedback may occur as a result of the failure with the system to meet a performance objective or as a result of changes in redefinition of System activities. The basic WATERFALL MODEL is being used that is it's stages.

These are as follows:- Requirement Analysis Phase

Design Phase

Development Phase

Coding Phase

Testing Phase

Implementation Phase

Post Implementation Phase

Phases of Waterfall Model:

REQUIREMENT ANALYSISThis phase includes the definition of the problem. In order to identify the problem: we have to know information about the problem the purpose of the evaluation for the problem to be known. To know the clients requirements and the objectives of the project, a questionnaire was prepared and the client was made to answer it. On the basis of the questionnaire, the problem is defined and evaluated. The SRS is made and requirement analysis is done.

DESIGNSoftware design is processes through which the requirements are translated into are presentation of software. The design of the system is in modular form i.e. the software is logically partitioned into components that perform specific functions and sub functions. TheDesign Phase leads to modules like process selection which exhibit independent functional characteristics .These modules arent interconnected. It even leads to interfaces that reduce the complexity of the connections between modules and with that external environment.

DEVELOPMENTThe development phase includes choosing of a suitable s/w to solve the particular problem given the various facilities and the sophistication in the selected software gives a better development of the problem. Here the software was built using. The data is stored in Database files for easier access.

CODINGThe coding phase is for retranslating the design of the system produced during the design phase into code in a given programming language which can be executed by a computer and which performs the computation specified by the design. We have used JAVA language and its basic concepts for coding the software system.

TESTINGTesting is done in various ways such as testing the algorithm, programming code, sample data debugging is one. Testing has been done by checking each and every module and also to check the validations.

IMPLEMENTATIONAfter testing is over project is implemented by providing training to the users and providing manuals so that they can be refreshed as and when needed.

POST IMPLEMENTATIONIf any problem occurs after the implemented they are removed from time to time so that so that the users can work on the prepared system easily finally a satisfied user when all things are almost right.LIBRARY MANAGEMENT SYSTEM

Sumeet Dhende (2012450009)Jeet Dholakia (2012450010)Page 2

CHAPTER 4PROJECT IMPLEMENTATION4.1 Work Breakdown Structure

Library ManagementSystem

ReserveLoanSearchMembersBooks

Help

BorrowAddAdd

About UsReturnList AllList All

DetailsEditAvailable

InfoRemoveEditBorrowed

Remove

4.2 Gantt Chart

4.3 Pert Chart

4.4 Code with reference to designAddBooks.java//import the packages for using the classes in them into the programimport javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;public class AddBooks extends JInternalFrame { //for creating the North Panel private JPanel northPanel = new JPanel(); //for creaing the North Label private JLabel northLabel = new JLabel("BOOK INFORMATION"); //for creating the Center Panel private JPanel centerPanel = new JPanel(); //for creating an Internal Panel in the center panel private JPanel informationLabelPanel = new JPanel(); //for creating an array of JLabel private JLabel[] informationLabel = new JLabel[10]; private JLabel lblShelfNo = new JLabel(" Shelf No"); private JTextField txtShelfNo = new JTextField(); //for creating an array of String private String[] informationString = { " The book subject: ", " The book title: ", " The name of the Author(s): ", " The name of the Publisher: ", " Copyright for the book: ", " The edition number: ", " The number of Pages: ", " ISBN for the book: ", " The number of copies: ", " The name of the Library: " }; //for creating an Internal Panel in the center panel private JPanel informationTextFieldPanel = new JPanel(); //for creating an array of JTextField private JTextField[] informationTextField = new JTextField[10]; //for creating an Internal Panel in the center panel private JPanel insertInformationButtonPanel = new JPanel(); //for creating a button private JButton insertInformationButton = new JButton("Insert the Information"); //for creating South Panel private JPanel southPanel = new JPanel(); //for creating a button private JButton OKButton = new JButton("Exit"); //create objects from another classes for using them in the ActionListener private Books book; //for creating an array of string to store the data private String[] data; //for setting availble option to true private boolean availble = true; //for checking the information from the text field public boolean isCorrect() { data = new String[10]; for (int i = 0; i < informationLabel.length; i++) { if (!informationTextField[i].getText().equals("")) { data[i] = informationTextField[i].getText(); } else { return false; } } return true; } //for setting the array of JTextField to empty public void clearTextField() { for (int i = 0; i < informationTextField.length; i++) { informationTextField[i].setText(null); } txtShelfNo.setText(null); } //constructor of addBooks public AddBooks() { //for setting the title for the internal frame super("Add Books", false, true, false, true); //for setting the icon setFrameIcon(new ImageIcon(ClassLoader.getSystemResource("images/Add16.gif"))); //for getting the graphical user interface components display area Container cp = getContentPane(); //for setting the layout northPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); //for setting the font for the North Panel northLabel.setFont(new Font("Tahoma", Font.BOLD, 14)); //for adding the label in the North Panel northPanel.add(northLabel); //for adding the north panel to the container cp.add("North", northPanel); //for setting the layout centerPanel.setLayout(new BorderLayout()); //for setting the border to the panel centerPanel.setBorder(BorderFactory.createTitledBorder("Add a new book:")); //for setting the layout informationLabelPanel.setLayout(new GridLayout(11, 1, 1, 1)); for (int i = 0; i < informationLabel.length; i++) { informationLabelPanel.add(informationLabel[i] = new JLabel(informationString[i])); informationLabel[i].setFont(new Font("Tahoma", Font.BOLD, 11)); } centerPanel.add("West", informationLabelPanel); //for setting the layout informationTextFieldPanel.setLayout(new GridLayout(11, 1, 1, 1)); for (int i = 0; i < informationTextField.length; i++) { informationTextFieldPanel.add(informationTextField[i] = new JTextField(25)); informationTextField[i].setFont(new Font("Tahoma", Font.PLAIN, 11)); } lblShelfNo.setFont(new Font("Tahoma", Font.BOLD, 11)); informationLabelPanel.add(lblShelfNo); txtShelfNo.setFont(new Font("Tahoma", Font.PLAIN, 11)); informationTextFieldPanel.add(txtShelfNo); centerPanel.add("East", informationTextFieldPanel); insertInformationButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); insertInformationButton.setFont(new Font("Tahoma", Font.BOLD, 11)); insertInformationButtonPanel.add(insertInformationButton); centerPanel.add("South", insertInformationButtonPanel); cp.add("Center", centerPanel);

southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); OKButton.setFont(new Font("Tahoma", Font.BOLD, 11)); southPanel.add(OKButton); southPanel.setBorder(BorderFactory.createEtchedBorder()); cp.add("South", southPanel); insertInformationButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { //for checking if there is a missing information if (isCorrect()) { Thread runner = new Thread() { public void run() { book = new Books(); //for checking if there is no double information in the database book.connection("SELECT BookID FROM Books WHERE ISBN = '" + data[7] + "'"); String ISBN = book.getISBN(); if (!data[7].equalsIgnoreCase(ISBN)) { try{ String sql="INSERT INTO Books (Subject,Title,Author,Publisher,Copyright," + "Edition,Pages,ISBN,NumberOfBooks,NumberOfAvailbleBooks,Library,Availble,ShelfNo) VALUES "+ " (?,?,?,?,?,?,?,?,?,?,?,?,?)"; /*String url = "jdbc:mysql://localhost:3306/"; String dbName = "lmsDb"; String driver = "com.mysql.jdbc.Driver"; String userName = "root"; String password = "";*/ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/jlibrary","root","pat123"); //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Connection con=DriverManager.getConnection("jdbc:odbc:JLibrary"); PreparedStatement ps=con.prepareStatement(sql); ps.setString(1, data[0]); ps.setString(2, data[1]); ps.setString(3, data[2]); ps.setString(4, data[3]); ps.setInt(5, Integer.parseInt(data[4])); ps.setInt(6,Integer.parseInt(data[5])); ps.setInt(7, Integer.parseInt(data[6])); ps.setString(8, data[7]); ps.setInt(9, Integer.parseInt(data[8])); ps.setInt(10, Integer.parseInt(data[8])); ps.setString(11, data[9]); ps.setBoolean(12, availble); ps.setInt(13, Integer.parseInt(txtShelfNo.getText())); ps.executeUpdate(); }catch(Exception ex){ JOptionPane.showMessageDialog(null, ex.toString()); } /*String sql="INSERT INTO Books (Subject,Title,Author,Publisher,Copyright," + "Edition,Pages,ISBN,NumberOfBooks,NumberOfAvailbleBooks,Library,Availble,ShelfNo) VALUES ('" + data[0] + "','" + data[1] + "','" + data[2] + "','" + data[3] + "', " + data[4] + ", " + data[5] + ", " + data[6] + ", '" + data[7] + "', " + data[8] + "," + data[8] + ",'" + data[9] + "', " + availble + ", '" + txtShelfNo.getText() + "')"; book.update(sql);*/ //JOptionPane.showMessageDialog(null, sql); //for setting the array of JTextField to empty clearTextField(); } else { JOptionPane.showMessageDialog(null, "The book is in the library", "Error", JOptionPane.ERROR_MESSAGE); } } }; runner.start(); } //if there is a missing data, then display Message Dialog else { JOptionPane.showMessageDialog(null, "Please, complete the information", "Warning", JOptionPane.WARNING_MESSAGE); } } }); //for adding the action listener for the button to dispose the frame OKButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { dispose(); } }); //for setting the visible to true setVisible(true); //show the internal frame pack(); }}AddMembers.java//import the packages for using the classes in them into the programimport javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;public class AddMembers extends JInternalFrame {//for creating the North Panelprivate JPanel northPanel = new JPanel();//for creaing the North Labelprivate JLabel northLabel = new JLabel("MEMBER INFORMATION");//for creating the Center Panelprivate JPanel centerPanel = new JPanel();//for creating an Internal Panel in the center panelprivate JPanel informationLabelPanel = new JPanel();//for creating an array of JLabelprivate JLabel[] informationLabel = new JLabel[7];//for creating an array of Stringprivate String[] informaionString = {" Member ID: ", " The Password: ", " Rewrite the password: ", " The Name: ", " E-MAIL: ", " Major:", " Expired: "};//for creating an Internal Panel in the center panelprivate JPanel informationTextFieldPanel = new JPanel();//for creating an array of JTextFieldprivate JTextField[] informationTextField = new JTextField[5];//for creating an array of JPasswordFieldprivate JPasswordField[] informationPasswordField = new JPasswordField[2];//for creating an Internal Panel in the center panelprivate JPanel insertInformationButtonPanel = new JPanel();//for creating a buttonprivate JButton insertInformationButton = new JButton("Insert the Information");

//for creating the South Panelprivate JPanel southPanel = new JPanel();//for creating a buttonprivate JButton OKButton = new JButton("Exit");//create objects from another classes for using them in the ActionListenerprivate Members member;//for creating an array of string to store the dataprivate String[] data;//for checking the passwordpublic boolean isPasswordCorrect() {if (informationPasswordField[0].getText().equals(informationPasswordField[1].getText()))data[1] = informationPasswordField[1].getText();else if (!informationPasswordField[0].getText().equals(informationPasswordField[1].getText()))return false;

return true;}//for checking the information from the text fieldpublic boolean isCorrect() {data = new String[6];for (int i = 0; i < informationLabel.length; i++) {if (i == 0) {if (!informationTextField[i].getText().equals("")) {data[i] = informationTextField[i].getText();}elsereturn false;}if (i == 1 || i == 2) {if (informationPasswordField[i - 1].getText().equals(""))return false;}if (i == 3 || i == 4 || i == 5 || i == 6) {if (!informationTextField[i - 2].getText().equals("")) {data[i - 1] = informationTextField[i - 2].getText();}elsereturn false;}}return true;}//for setting the array of JTextField & JPasswordField to nullpublic void clearTextField() {for (int i = 0; i < informationLabel.length; i++) {if (i == 0)informationTextField[i].setText(null);if (i == 1 || i == 2)informationPasswordField[i - 1].setText(null);if (i == 3 || i == 4 || i == 5 || i == 6)informationTextField[i - 2].setText(null);}}//constructor of addMemberspublic AddMembers() {//for setting the title for the internal framesuper("Add Members", false, true, false, true);//for setting the iconsetFrameIcon(new ImageIcon(ClassLoader.getSystemResource("images/Add16.gif")));//for getting the graphical user interface components display areaContainer cp = getContentPane();//for setting the layoutnorthPanel.setLayout(new FlowLayout(FlowLayout.CENTER));//for setting the fontnorthLabel.setFont(new Font("Tahoma", Font.BOLD, 14));//for adding the label to the panelnorthPanel.add(northLabel);//for adding the panel to the containercp.add("North", northPanel);//for setting the layoutcenterPanel.setLayout(new BorderLayout());//for setting the border to the panelcenterPanel.setBorder(BorderFactory.createTitledBorder("Add a new member:"));//for setting the layoutinformationLabelPanel.setLayout(new GridLayout(7, 1, 1, 1));//for setting the layoutinformationTextFieldPanel.setLayout(new GridLayout(7, 1, 1, 1));for (int i = 0; i < informationLabel.length; i++) {informationLabelPanel.add(informationLabel[i] = new JLabel(informaionString[i]));informationLabel[i].setFont(new Font("Tahoma", Font.BOLD, 11));}//for adding the panel to the centerPanelcenterPanel.add("West", informationLabelPanel);for (int i = 0; i < informationLabel.length; i++) {if (i == 1 || i == 2) {informationTextFieldPanel.add(informationPasswordField[i - 1] = new JPasswordField(25));informationPasswordField[i - 1].setFont(new Font("Tahoma", Font.PLAIN, 11));}if (i == 0) {informationTextFieldPanel.add(informationTextField[i] = new JTextField(25));informationTextField[i].setFont(new Font("Tahoma", Font.PLAIN, 11));}if (i == 3 || i == 4 || i == 5 || i == 6) {informationTextFieldPanel.add(informationTextField[i - 2] = new JTextField(25));informationTextField[i - 2].setFont(new Font("Tahoma", Font.PLAIN, 11));}}centerPanel.add("East", informationTextFieldPanel);insertInformationButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));insertInformationButton.setFont(new Font("Tahoma", Font.BOLD, 11));insertInformationButtonPanel.add(insertInformationButton);centerPanel.add("South", insertInformationButtonPanel);cp.add("Center", centerPanel);southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));OKButton.setFont(new Font("Tahoma", Font.BOLD, 11));southPanel.add(OKButton);southPanel.setBorder(BorderFactory.createEtchedBorder());cp.add("South", southPanel);insertInformationButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent ae) {//for checking if there is a missing informationif (isCorrect()) {if (isPasswordCorrect()) {Thread runner = new Thread() {public void run() {member = new Members();//for checking if there is no same information in the databasemember.connection("SELECT * FROM Members WHERE ID = " + data[0]);int ID = member.getID();if (Integer.parseInt(data[0]) != ID) {member.update("INSERT INTO Members (ID,Password,Name,EMail,Major,Expired) VALUES (" + data[0] + ", '" + data[1] + "','" + data[2] + "','" + data[3] + "','" + data[4] + "','" + data[5] + "')");//for setting the array of JTextField & JPasswordField to nullclearTextField();}elseJOptionPane.showMessageDialog(null, "Member is in the Library", "Error", JOptionPane.ERROR_MESSAGE);}};runner.start();}//if the password is wrongelseJOptionPane.showMessageDialog(null, "the passowrd is wrong", "Error", JOptionPane.ERROR_MESSAGE);}//if there is a missing data, then display Message DialogelseJOptionPane.showMessageDialog(null, "Please, complete the information", "Warning", JOptionPane.WARNING_MESSAGE);}});//for adding the action listener for the button to dispose the frameOKButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent ae) {dispose();}});//for setting the visible to truesetVisible(true);//show the internal framepack();}}Books.java//import the packages for using the classes in them into the programimport java.sql.*;public class Books {private Connection connection = null;private Statement statement = null;private ResultSet resultSet = null;private int bookID;private String subject;private String title;private String author;private String publisher;private int copyright;private int edition;private int pages;private String ISBN;private int numberOfBooks;private int numberOfAvailbleBooks;private int numberOfBorrowedBooks;private String library;private boolean availble;private String URL = "jdbc:mysql://localhost:3306/jlibrary";public Books() {}public int getBookID() {return bookID;}public String getSubject() {return subject;}public String getTitle() {return title;}public String getAuthor() {return author;}public String getPublisher() {return publisher;}public int getCopyright() {return copyright;}public int getEdition() {return edition;}public int getPages() {return pages;}public String getISBN() {return ISBN;}public int getNumberOfBooks() {return numberOfBooks;}public int getNumberOfAvailbleBooks() {return numberOfAvailbleBooks;}public int getNumberOfBorrowedBooks() {return numberOfBorrowedBooks;}public String getLibrary() {return library;}public boolean getAvailble() {return availble;}public void connection(String Query) {try {Class.forName("com.mysql.jdbc.Driver");}catch (ClassNotFoundException cnfe) {System.out.println("Books.java\n" + cnfe.toString());}catch (Exception e) {System.out.println("Books.java\n" + e.toString());}try {connection = DriverManager.getConnection(URL,"root","pat123");statement = connection.createStatement();resultSet = statement.executeQuery(Query);while (resultSet.next()) {bookID = resultSet.getInt(1);subject = resultSet.getString(2);title = resultSet.getString(3);author = resultSet.getString(4);publisher = resultSet.getString(5);copyright = resultSet.getInt(6);edition = resultSet.getInt(7);pages = resultSet.getInt(8);ISBN = resultSet.getString(9);numberOfBooks = resultSet.getInt(10);numberOfAvailbleBooks = resultSet.getInt(11);numberOfBorrowedBooks = resultSet.getInt(12);library = resultSet.getString(13);availble = resultSet.getBoolean(14);}resultSet.close();statement.close();connection.close();}catch (SQLException SQLe) {System.out.println("Books.java\n" + SQLe.toString());}}public void update(String Query) {try {Class.forName("com.mysql.jdbc.Driver");}catch (ClassNotFoundException cnfe) {System.out.println("Books.java\n" + cnfe.toString());}catch (Exception e) {System.out.println("Books.java\n" + e.toString());}try {//connection = DriverManager.getConnection("jdbc:odbc:JLibrary2");connection = DriverManager.getConnection(URL,"root","pat123");statement = connection.createStatement();statement.executeUpdate(Query);statement.close();connection.close();}catch (SQLException SQLe) {System.out.println("Books.java\nError:" + SQLe.toString());}}}Borrow.java//import the packages for using the classes in them into the programimport java.sql.*;public class Borrow {private Connection connection = null;private Statement statement = null;private ResultSet resultSet = null;private int bookID;private int memberID;private Date dayOfBorrowed;private Date dayOfReturn;private String URL = "jdbc:mysql://localhost:3306/jlibrary";public Borrow() {}public int getBookID() {return bookID;}public int getMemberID() {return memberID;}public Date getDayOfBorrowed() {return dayOfBorrowed;}public Date getDayOfReturn() {return dayOfReturn;}

public void connection() {try {Class.forName("com.mysql.jdbc.Driver");}catch (ClassNotFoundException cnfe) {System.out.println("Borrow.java\n" + cnfe.toString());}catch (Exception e) {System.out.println("Borrow.java\n" + e.toString());}try {connection = DriverManager.getConnection(URL,"root","pat123");statement = connection.createStatement();resultSet = statement.executeQuery("SELECT * FROM Borrow");while (resultSet.next()) {bookID = resultSet.getInt(1);memberID = resultSet.getInt(2);dayOfBorrowed = resultSet.getDate(3);dayOfReturn = resultSet.getDate(4);}resultSet.close();statement.close();connection.close();}catch (SQLException SQLe) {System.out.println("Borrow.java\n" + SQLe.toString());}}public void update(String Query) {try {Class.forName("com.mysql.jdbc.Driver");}catch (ClassNotFoundException cnfe) {System.out.println("Borrow.java\n" + cnfe.toString());}catch (Exception e) {System.out.println("Borrow.java\n" + e.toString());}try {connection = DriverManager.getConnection(URL,"root","pat123");statement = connection.createStatement();statement.executeUpdate(Query);statement.close();connection.close();}catch (SQLException SQLe) {System.out.println("Borrow.java\n" + SQLe.toString());}}}Login.javaimport java.awt.EventQueue;public class login extends javax.swing.JFrame { public login() { initComponents(); } @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jPasswordField1 = new javax.swing.JPasswordField();setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("LOGIN"); setResizable(false); jLabel1.setText("USERNAME"); jLabel2.setText("PASSWORD"); jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField1ActionPerformed(evt); } }); jButton1.setText("LOGIN"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(78, 78, 78) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(57, 57, 57) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE) .addComponent(jPasswordField1))) .addGroup(layout.createSequentialGroup() .addGap(136, 136, 136) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(84, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(115, 115, 115) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addGroup(layout.createSequentialGroup() .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton1))) .addContainerGap(81, Short.MAX_VALUE)) ); pack(); setLocationRelativeTo(null); }// //GEN-END:initComponents private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextField1ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed if(jTextField1.getText().equals("admin") && jPasswordField1.getText().equals("admin")) { //m =new Main(this); //m.setVisible(true); EventQueue.invokeLater(new Main(new JLibrary())); } }//GEN-LAST:event_jButton1ActionPerformed public static void main(String args[]) { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //

/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new login().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPasswordField jPasswordField1; private javax.swing.JTextField jTextField1; // End of variables declaration//GEN-END:variables}Main.java//import the packages for using the classes in them into the programimport java.awt.EventQueue;import java.awt.Frame;import javax.swing.JDialog;public class Main implements Runnable {final Frame frame;public Main(Frame frame) {this.frame = frame;}public void run() {frame.show();}public static void main(String[] args) {JDialog.setDefaultLookAndFeelDecorated(true);// Throw a nice little title page up on the screen firstnew Splash().showSplash(3000); new login().setVisible(true); //EventQueue.invokeLater(new Main(new JLibrary()));}}Members.java//import the packages for using the classes in them into the programimport java.sql.*;public class Members {private Connection connection = null;private Statement statement = null;private ResultSet resultSet = null;private int memberID;private int ID;private String password;private String name;private String email;private String major;private int numberOfBooks;private int mony;private Date expired;private String URL = "jdbc:mysql://localhost:3306/jlibrary";public Members() {}/*public Members(int memberID, int ID, String password, String name, String email, String major, int numberOfBooks, int mony, Date expired) {this.memberID = memberID;this.ID = ID;this.password = password;this.name = name;this.email = email;this.major = major;this.numberOfBooks = numberOfBooks;this.mony = mony;this.expired = expired;}*/public int getMemberID() {return memberID;}

public int getID() {return ID;}public String getPassword() {return password;}public String getName() {return name;}public String getEmail() {return email;}public String getMajor() {return major;}public int getNumberOfBooks() {return numberOfBooks;}

public int getMony() {return mony;}public Date getExpired() {return expired;}public void connection(String Query) {try {Class.forName("com.mysql.jdbc.Driver");}catch (ClassNotFoundException cnfe) {System.out.println("Members.java\n" + cnfe.toString());}catch (Exception e) {System.out.println("Members.java\n" + e.toString());}try {connection = DriverManager.getConnection(URL,"root","pat123");statement = connection.createStatement();resultSet = statement.executeQuery(Query);while (resultSet.next()) {memberID = resultSet.getInt(1);ID = resultSet.getInt(2);password = resultSet.getString(3);name = resultSet.getString(4);email = resultSet.getString(5);major = resultSet.getString(6);numberOfBooks = resultSet.getInt(7);mony = resultSet.getInt(8);expired = resultSet.getDate(9);}resultSet.close();statement.close();connection.close();}catch (SQLException SQLe) {System.out.println("Members.java\n" + SQLe.toString());}}

public void update(String Query) {try {Class.forName("com.mysql.jdbc.Driver");}catch (ClassNotFoundException cnfe) {System.out.println("Members.java\n" + cnfe.toString());}catch (Exception e) {System.out.println("Members.java\n" + e.toString());}try {connection = DriverManager.getConnection(URL,"root","pat123");statement = connection.createStatement();statement.executeUpdate(Query);statement.close();connection.close();}catch (SQLException SQLe) {System.out.println("Members.java\n" + SQLe.toString());}}}Splash.java//import the packages for using the classes in them into the programimport javax.swing.*;import java.awt.*;public class Splash { // A simple little method to show a title screen in the // center of the screen for a given amount of time. public void showSplash(int duration) { JWindow splash = new JWindow(); JPanel content = (JPanel) splash.getContentPane(); // set the window's bounds, centering the window int width = 354; int height = 268; Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - width) / 2; int y = (screen.height - height) / 2; splash.setBounds(x, y, width, height); // build the splash screen JLabel label = new JLabel(new ImageIcon(ClassLoader.getSystemResource("images/splash.JPG"))); JLabel copyrt = new JLabel("", JLabel.CENTER); copyrt.setFont(new Font("Tahoma", Font.BOLD, 10)); //copyrt.setBorder(BorderFactory.createEtchedBorder()); content.setBackground(Color.LIGHT_GRAY); //content.setBackground(new Color(232, 232, 228)); content.add(label, BorderLayout.CENTER); content.add(copyrt, BorderLayout.SOUTH); content.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); // display it splash.setVisible(true); // Wait a little while, maybe while loading resources try { Thread.sleep(duration); } catch (Exception e) { } splash.setVisible(false); }}Menubar.java//import the packages for using the classes in them into the programimport javax.swing.*;import java.awt.event.ActionEvent;import java.awt.event.KeyEvent;import javax.management.JMException;public class Menubar extends JMenuBar { //for creating the JMenu for the program public JMenu fileMenu, bookMenu, memberMenu, searchMenu, loanMenu, reserveMenu, helpMenu; //for creating the JMenuItem for JMenu public JMenuItem printBook, exit, addBook, listBook, listAvailbleBook, listBorrowedBook; public JMenuItem editBook, removeBook, bookInformation, addMember, listMember, editMember; public JMenuItem removeMember, memberInformation, searchBooksAndMembers, borrowBook, returnBook; public JMenuItem listissuedbooks,reserveBook, help, about; //for creating an imageIcon public ImageIcon[] icons; //for creating the name of the image file 16*16 public String[] imageName16 = {"images/Print16.gif", "images/Exit16.gif", "images/Add16.gif", "images/List16.gif", "images/Edit16.gif", "images/Delete16.gif", "images/Information16.gif", "images/Find16.gif", "images/Export16.gif", "images/Import16.gif", "images/Help16.gif", "images/About16.gif" }; public Menubar() { //for adding book, member, search, loan & help Menus to the menu bar this.add(fileMenu = new JMenu("File")); this.add(bookMenu = new JMenu("Books")); this.add(memberMenu = new JMenu("Members")); this.add(searchMenu = new JMenu("Search")); this.add(loanMenu = new JMenu("Loan")); this.add(reserveMenu = new JMenu("Reserve")); this.add(helpMenu = new JMenu("Help")); fileMenu.setMnemonic('f'); bookMenu.setMnemonic('b'); memberMenu.setMnemonic('m'); searchMenu.setMnemonic('s'); loanMenu.setMnemonic('l'); reserveMenu.setMnemonic('r'); helpMenu.setMnemonic('h'); //for setting the image icons icons = new ImageIcon[12]; for (int i = 0; i < imageName16.length; i++) { icons[i] = new ImageIcon(ClassLoader.getSystemResource(imageName16[i])); } //for adding print books & exit fileMenu.add(printBook = new JMenuItem("Print Books", icons[0])); fileMenu.add(exit = new JMenuItem("Exit", icons[1])); //for adding add, list, listAvailble, listBorrowed, edit & remove Books and book information to the bookMenu bookMenu.add(addBook = new JMenuItem("Add Book", icons[2])); bookMenu.add(listBook = new JMenuItem("List All Books", icons[3])); bookMenu.add(listAvailbleBook = new JMenuItem("List Availble Books", icons[3])); bookMenu.add(listBorrowedBook = new JMenuItem("List Borrowed Books", icons[3])); bookMenu.add(editBook = new JMenuItem("Edit Books", icons[4])); bookMenu.add(removeBook = new JMenuItem("Remove Book", icons[5])); //bookMenu.add(bookInformation = new JMenuItem("Book Information", icons[6])); //for adding add, list, edit & remove Members and member information to the memberMenu memberMenu.add(addMember = new JMenuItem("Add Member", icons[2])); memberMenu.add(listMember = new JMenuItem("List All Members", icons[3])); memberMenu.add(editMember = new JMenuItem("Edit Members", icons[4])); memberMenu.add(removeMember = new JMenuItem("Remove Member", icons[5])); memberMenu.add(memberInformation = new JMenuItem("Member Information", icons[6])); //for adding add, list & remove Members to the memberMenu searchMenu.add(searchBooksAndMembers = new JMenuItem("Search", icons[7])); //for adding borrow & return books to the loanMenu loanMenu.add(borrowBook = new JMenuItem("Borrow a Book", icons[8])); loanMenu.add(returnBook = new JMenuItem("Return a Book", icons[9])); loanMenu.add(listissuedbooks=new JMenuItem("Issued book details",icons[3])); //Reserve a book reserveMenu.add(reserveBook = new JMenuItem("Reserve a Book", icons[10])); //for adding help & about to the helpMenu helpMenu.add(help = new JMenuItem("Help", icons[10])); helpMenu.add(about = new JMenuItem("About", icons[11])); //for setting the shortcut printBook.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)); searchBooksAndMembers.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); addBook.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); listBook.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.CTRL_MASK)); editBook.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK)); removeBook.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); addMember.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK)); listMember.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK)); editMember.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK)); removeMember.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)); borrowBook.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK)); returnBook.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)); listissuedbooks.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,ActionEvent.CTRL_MASK)); help.setAccelerator(KeyStroke.getKeyStroke("F1")); about.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); }}PrintBooks.java//import the packages for using the classes in them into the programimport javax.swing.*;import java.awt.*;import java.awt.print.PageFormat;import java.awt.print.Printable;import java.awt.print.PrinterException;import java.sql.*;import java.util.StringTokenizer;import java.util.Vector;public class PrintingBooks extends JInternalFrame implements Printable {//for setting the connection and statementprivate Connection connection = null;private Statement statement = null;private ResultSet resultset = null;

private String URL = "jdbc:mysql://localhost:3306/jlibrary";//for creating the text areaprivate JTextArea textArea = new JTextArea();//for creating the vector to use it in the printprivate Vector lines;public static final int TAB_SIZE = 5;//constructor of JLibrarypublic PrintingBooks(String query) {super("Printing Books", false, true, false, true);//for getting the graphical user interface components display areaContainer cp = getContentPane();//for setting the fonttextArea.setFont(new Font("Tahoma", Font.PLAIN, 9));//for adding the textarea to the containercp.add(textArea);try {Class.forName("com.mysql.jdbc.Driver");}catch (ClassNotFoundException ea) {System.out.println(ea.toString());}catch (Exception e) {System.out.println(e.toString());}try {connection = DriverManager.getConnection(URL);statement = connection.createStatement();resultset = statement.executeQuery(query);textArea.append("=============== Books Information ===============\n\n");while (resultset.next()) {textArea.append("Subject: " + resultset.getString("Subject") + "\n" + "Title: " + resultset.getString("Title") + "\n" + "Author(s): " + resultset.getString("Author") + "\n" + "Copyright: " + resultset.getString("Copyright") + "\n" + "Edition: " + resultset.getString("Edition") + "\n" + "ISBN: " + resultset.getString("ISBN") + "\n" + "Library: " + resultset.getString("Library") + "\n\n");}textArea.append("=============== Books Information ===============");resultset.close();statement.close();connection.close();}catch (SQLException SQLe) {System.out.println(SQLe.toString());}//for setting the visible to truesetVisible(true);//to show the framepack();}public int print(Graphics pg, PageFormat pageFormat, int pageIndex) throws PrinterException {pg.translate((int) pageFormat.getImageableX(), (int) pageFormat.getImageableY());int wPage = (int) pageFormat.getImageableWidth();int hPage = (int) pageFormat.getImageableHeight();pg.setClip(0, 0, wPage, hPage);pg.setColor(textArea.getBackground());pg.fillRect(0, 0, wPage, hPage);pg.setColor(textArea.getForeground());Font font = textArea.getFont();pg.setFont(font);FontMetrics fm = pg.getFontMetrics();int hLine = fm.getHeight();if (lines == null)lines = getLines(fm, wPage);int numLines = lines.size();int linesPerPage = Math.max(hPage / hLine, 1);int numPages = (int) Math.ceil((double) numLines / (double) linesPerPage);if (pageIndex >= numPages) {lines = null;return NO_SUCH_PAGE;}int x = 0;int y = fm.getAscent();int lineIndex = linesPerPage * pageIndex;while (lineIndex < lines.size() && y < hPage) {String str = (String) lines.get(lineIndex);pg.drawString(str, x, y);y += hLine;lineIndex++;}return PAGE_EXISTS;}

protected Vector getLines(FontMetrics fm, int wPage) {Vector v = new Vector();String text = textArea.getText();String prevToken = "";StringTokenizer st = new StringTokenizer(text, "\n\r", true);while (st.hasMoreTokens()) {String line = st.nextToken();if (line.equals("\r"))continue;// StringTokenizer will ignore empty lines, so it's a bit tricky to get them...if (line.equals("\n") && prevToken.equals("\n"))v.add("");prevToken = line;if (line.equals("\n"))continue;

StringTokenizer st2 = new StringTokenizer(line, " \t", true);String line2 = "";while (st2.hasMoreTokens()) {String token = st2.nextToken();if (token.equals("\t")) {int numSpaces = TAB_SIZE - line2.length() % TAB_SIZE;token = "";for (int k = 0; k < numSpaces; k++)token += " ";}int lineLength = fm.stringWidth(line2 + token);if (lineLength > wPage && line2.length() > 0) {v.add(line2);line2 = token.trim();continue;}line2 += token;}v.add(line2);}return v;}}

ResultSetTableModel.javaimport javax.swing.table.AbstractTableModel;import java.sql.*;public class ResultSetTableModel extends AbstractTableModel {private Connection connection;private Statement statement;private ResultSet resultSet;private ResultSetMetaData metaData;private int numberOfRows;// keep track of database connection statusprivate boolean connectedToDatabase = false;// initialize resultSet and obtain its meta data object;// determine number of rowspublic ResultSetTableModel(String driver, String url, String query) throws SQLException, ClassNotFoundException {Class.forName(driver); // load database driver classconnection = DriverManager.getConnection(url,"root","pat123"); // connect to database// create Statement to query databasestatement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);connectedToDatabase = true; // update database connection statussetQuery(query); // set query and execute it}

// get class that represents column typepublic Class getColumnClass(int column) throws IllegalStateException {// ensure database connection is availableif (!connectedToDatabase) throw new IllegalStateException("Not Connected to Database");// determine Java class of columntry {String className = metaData.getColumnClassName(column + 1);return Class.forName(className); // return Class object that represents className} // catch SQLExceptions and ClassNotFoundExceptionscatch (Exception exception) {exception.printStackTrace();}// if problems occur above, assume type Objectreturn Object.class;}// get number of columns in ResultSetpublic int getColumnCount() throws IllegalStateException {// ensure database connection is availableif (!connectedToDatabase) throw new IllegalStateException("Not Connected to Database");// determine number of columnstry {return metaData.getColumnCount();} // catch SQLExceptions and print error messagecatch (SQLException sqlException) {sqlException.printStackTrace();}// if problems occur above, return 0 for number of columnsreturn 0;}// get name of a particular column in ResultSetpublic String getColumnName(int column) throws IllegalStateException {// ensure database connection is availableif (!connectedToDatabase) throw new IllegalStateException("Not Connected to Database");// determine column nametry {return metaData.getColumnName(column + 1);} // catch SQLExceptions and print error messagecatch (SQLException sqlException) {sqlException.printStackTrace();}// if problems, return empty string for column namereturn "";}

// return number of rows in ResultSetpublic int getRowCount() throws IllegalStateException {// ensure database connection is availableif (!connectedToDatabase) throw new IllegalStateException("Not Connected to Database");return numberOfRows;}// obtain value in particular row and columnpublic Object getValueAt(int row, int column) throws IllegalStateException {// ensure database connection is availableif (!connectedToDatabase) throw new IllegalStateException("Not Connected to Database");// obtain a value at specified ResultSet row and columntry {resultSet.absolute(row + 1);return resultSet.getObject(column + 1);} // catch SQLExceptions and print error messagecatch (SQLException sqlException) {sqlException.printStackTrace();}// if problems, return empty string objectreturn "";}

// set new database query stringpublic void setQuery(String query) throws SQLException, IllegalStateException {// ensure database connection is availableif (!connectedToDatabase) throw new IllegalStateException("Not Connected to Database");// specify query and execute itresultSet = statement.executeQuery(query);// obtain meta data for ResultSetmetaData = resultSet.getMetaData();// determine number of rows in ResultSetresultSet.last(); // move to last rownumberOfRows = resultSet.getRow(); // get row numberfireTableStructureChanged(); // notify JTable that model has changed}// close Statement and Connectionpublic void disconnectFromDatabase() {// close Statement and Connectiontry {statement.close();connection.close();} // catch SQLExceptions and print error messagecatch (SQLException sqlException) {sqlException.printStackTrace();} // update database connection statusfinally {connectedToDatabase = false;}}} // end class ResultSetTableModelMembersInformation.java//import the packages for using the classes in them into the programimport javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;//for creating the North Panelprivate JPanel northPanel = new JPanel();//for creaing the North Labelprivate JLabel northLabel = new JLabel("MEMBER INFORMATION");//for creating the Center Panelprivate JPanel centerPanel = new JPanel();//for creating the edit Panelprivate JPanel memberIDPanel = new JPanel();//for creating the edit information Panelprivate JPanel memberIDInformationPanel = new JPanel();//for creating the edit label panelprivate JPanel memberIDInformationLabelPanel = new JPanel();//for creating the edit textField panelprivate JPanel memberIDInformationTextFieldPanel = new JPanel();//for creating the edit button panelprivate JPanel memberIDButtonPanel = new JPanel();//for creating the labelprivate JLabel memberIDLabel = new JLabel("MemberID: ");//for creating the textFieldprivate JTextField memberIDTextField = new JTextField(25);//for creating the buttonprivate JButton memberIDButton = new JButton("OK");//for creating the information Panelprivate JPanel informationPanel = new JPanel();//for creating an Internal Panel in the center panelprivate JPanel informationLabelPanel = new JPanel();//for creating an array of JLabelprivate JLabel[] informationLabel = new JLabel[7];//for creating an array of Stringprivate String[] informaionString = {" Member ID: ", " The Password: ", " Rewrite the password: ", " The Name: ", " E-MAIL: ", " Major:", " Expired: "};//for creating an Internal Panel in the center panelprivate JPanel informationTextFieldPanel = new JPanel();//for creating an array of JTextFieldprivate JTextField[] informationTextField = new JTextField[5];//for creating an array of JPasswordFieldprivate JPasswordField[] informationPasswordField = new JPasswordField[2];//for creating an Internal Panel in the center panelprivate JPanel InformationButtonPanel = new JPanel();//for creating a buttonprivate JButton fButton = new JButton(">");//for creating the South Panelprivate JPanel southPanel = new JPanel();//for creating a buttonprivate JButton exitButton = new JButton("Exit");//create objects from another classes for using them in the ActionListenerprivate Members member;//for creating an array of string to store the dataprivate String[] data;//for checking the passwordpublic boolean isPasswordCorrect() {if (informationPasswordField[0].getText().equals(informationPasswordField[1].getText()))data[1] = informationPasswordField[0].getText();else if (!informationPasswordField[0].getText().equals(informationPasswordField[1].getText()))return false;

return true;}//for checking the information from the text fieldpublic boolean isCorrect() {data = new String[6];for (int i = 0; i < informationLabel.length; i++) {if (i == 0) {if (!informationTextField[i].getText().equals("")) {data[i] = informationTextField[i].getText();}elsereturn false;}if (i == 1 || i == 2) {if (informationPasswordField[i - 1].getText().equals(""))return false;}if (i == 3 || i == 4 || i == 5 || i == 6) {if (!informationTextField[i - 2].getText().equals("")) {data[i - 1] = informationTextField[i - 2].getText();}elsereturn false;}}return true;}//for checking the information from the text fieldpublic boolean isEditCorrect() {if (memberIDTextField.getText().equals(""))return false;return true;}//for setting the array of JTextField & JPasswordField to nullpublic void clearTextField() {memberIDTextField.setText(null);for (int i = 0; i < informationLabel.length; i++) {if (i == 0)informationTextField[i].setText(null);if (i == 1 || i == 2)informationPasswordField[i - 1].setText(null);if (i == 3 || i == 4 || i == 5 || i == 6)informationTextField[i - 2].setText(null);}}//constructor of addMemberspublic MembersInformation() {//for setting the title for the internal framesuper("Members Information", false, true, false, true);//for setting the iconsetFrameIcon(new ImageIcon(ClassLoader.getSystemResource("images/Information16.gif")));//for getting the graphical user interface components display areaContainer cp = getContentPane();//for setting the layoutnorthPanel.setLayout(new FlowLayout(FlowLayout.CENTER));//for setting the fontnorthLabel.setFont(new Font("Tahoma", Font.BOLD, 14));//for adding the label to the panelnorthPanel.add(northLabel);//for adding the panel to the containercp.add("North", northPanel);//for setting the layoutcenterPanel.setLayout(new BorderLayout());//for setting the layoutmemberIDPanel.setLayout(new BorderLayout());//for setting the border to the panelmemberIDPanel.setBorder(BorderFactory.createTitledBorder("MemberID: "));//for setting the layoutmemberIDInformationPanel.setLayout(new BorderLayout());//for setting the layoutmemberIDInformationLabelPanel.setLayout(new GridLayout(1, 1, 1, 1));//for adding the label to the panelmemberIDInformationLabelPanel.add(memberIDLabel);//for setting the font to the labelmemberIDLabel.setFont(new Font("Tahoma", Font.BOLD, 11));//for adding the editInformationLabelPanel to the editInformationLabelmemberIDInformationPanel.add("West", memberIDInformationLabelPanel);//for setting the layoutmemberIDInformationTextFieldPanel.setLayout(new GridLayout(1, 1, 1, 1));//for adding the textField to the panelmemberIDInformationTextFieldPanel.add(memberIDTextField);//for setting the font to the textFieldmemberIDTextField.setFont(new Font("Tahoma", Font.PLAIN, 11));//for adding the editInformationTextField to the editInformationPanelmemberIDInformationPanel.add("East", memberIDInformationTextFieldPanel);//for adding the editInformationPanel to the editPanelmemberIDPanel.add("North", memberIDInformationPanel);//for setting the layoutmemberIDButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));//for adding the button to the panelmemberIDButtonPanel.add(memberIDButton);//for setting the fonr to the buttonmemberIDButton.setFont(new Font("Tahoma", Font.BOLD, 11));//for adding the editInformationButtonPanel to the editPanelmemberIDPanel.add("Center", memberIDButtonPanel);//for adding the editPanel to the centerPanelcenterPanel.add("North", memberIDPanel);//for setting the layoutinformationPanel.setLayout(new BorderLayout());//for setting the border to the panelinformationPanel.setBorder(BorderFactory.createTitledBorder("Edit a member: "));//for setting the layoutinformationLabelPanel.setLayout(new GridLayout(7, 1, 1, 1));//for setting the layoutinformationTextFieldPanel.setLayout(new GridLayout(7, 1, 1, 1));for (int i = 0; i < informationLabel.length; i++) {informationLabelPanel.add(informationLabel[i] = new JLabel(informaionString[i]));informationLabel[i].setFont(new Font("Tahoma", Font.BOLD, 11));}//for adding the panel to the centerPanelinformationPanel.add("West", informationLabelPanel);for (int i = 0; i < informationLabel.length; i++) {if (i == 1 || i == 2) {informationTextFieldPanel.add(informationPasswordField[i - 1] = new JPasswordField(25));informationPasswordField[i - 1].setFont(new Font("Tahoma", Font.PLAIN, 11));informationPasswordField[i - 1].setEnabled(false);}if (i == 0) {informationTextFieldPanel.add(informationTextField[i] = new JTextField(25));informationTextField[i].setFont(new Font("Tahoma", Font.PLAIN, 11));informationTextField[i].setEditable(false);}if (i == 3 || i == 4 || i == 5 || i == 6) {informationTextFieldPanel.add(informationTextField[i - 2] = new JTextField(25));informationTextField[i - 2].setFont(new Font("Tahoma", Font.PLAIN, 11));informationTextField[i - 2].setEditable(false);}}informationPanel.add("East", informationTextFieldPanel);InformationButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));fButton.setFont(new Font("Tahoma", Font.BOLD, 11));InformationButtonPanel.add(fButton);informationPanel.add("South", InformationButtonPanel);centerPanel.add("Center", informationPanel);cp.add("Center", centerPanel);southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));exitButton.setFont(new Font("Tahoma", Font.BOLD, 11));southPanel.add(exitButton);southPanel.setBorder(BorderFactory.createEtchedBorder());cp.add("South", southPanel);

//for adding the action listener for the button to dispose the frameexitButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent ae) {dispose();}});//for setting the visible to truesetVisible(true);//show the internal framepack();}}RemoveBooks.java//import the packages for using the classes in them into the programimport javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;//for creating the North Panelprivate JPanel northPanel = new JPanel();//for creating the labelprivate JLabel title = new JLabel("BOOK INFORMATION");//for creating the Center Panelprivate JPanel centerPanel = new JPanel();//for creating an Internal Panel in the center panelprivate JPanel removePanel = new JPanel();//for creating the labelprivate JLabel removeLabel = new JLabel(" Write the Book ID: ");//for creating the text fieldprivate JTextField removeTextField = new JTextField();//for creating string to store the dataprivate String data;//for creating an Internal Panel in the center panelprivate JPanel removeMemberPanel = new JPanel();//for creating the buttonprivate JButton removeButton = new JButton("Remove");//for creating the South Panelprivate JPanel southPanel = new JPanel();//for adding the buttonprivate JButton exitButton = new JButton("Exit");//create objects from another classes for using them in the ActionListenerprivate Books book;//for checking the information from the text fieldpublic boolean isCorrect() {if (!removeTextField.getText().equals("")) {data = removeTextField.getText();return true;}elsereturn false;}

//constructor of removeBookspublic RemoveBooks() {//for setting the title for the internal framesuper("Remove Books", false, true, false, true);//for setting the iconsetFrameIcon(new ImageIcon(ClassLoader.getSystemResource("images/Delete16.gif")));//for getting the graphical user interface components display areaContainer cp = getContentPane();//for setting the layoutnorthPanel.setLayout(new FlowLayout(FlowLayout.CENTER));//for setting the fonttitle.setFont(new Font("Tahoma", Font.BOLD, 14));//for adding the labelnorthPanel.add(title);//for adding the panel to the containercp.add("North", northPanel);//for setting the layoutcenterPanel.setLayout(new BorderLayout());//for setting the layoutremovePanel.setLayout(new GridLayout(1, 2, 1, 1));//for adding the labelremovePanel.add(removeLabel);//for adding the text fieldremovePanel.add(removeTextField);//for adding the internal panel to the panelcenterPanel.add("Center", removePanel);

//for setting the layoutremoveMemberPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));//for adding the buttonremoveMemberPanel.add(removeButton);//for addint the internal panel to the center panelcenterPanel.add("South", removeMemberPanel);//for setting the bordercenterPanel.setBorder(BorderFactory.createTitledBorder("Remove a book:"));//for adding the center panel to the containercp.add("Center", centerPanel);removeLabel.setFont(new Font("Tahoma", Font.BOLD, 11));removeTextField.setFont(new Font("Tahoma", Font.PLAIN, 11));exitButton.setFont(new Font("Tahoma", Font.BOLD, 11));removeButton.setFont(new Font("Tahoma", Font.BOLD, 11));//for setting the layoutsouthPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));//for adding the buttonsouthPanel.add(exitButton);//for setting the bordersouthPanel.setBorder(BorderFactory.createEtchedBorder());//for add the south panel to the containercp.add("South", southPanel);removeButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent ae) {//for checking if there is a missing informationif (isCorrect()) {Thread runner = new Thread() {public void run() {book = new Books();//for getting the informationbook.connection("SELECT * FROM Books WHERE BookID =" + data);int bookID = book.getBookID();int numberOfBooks = book.getNumberOfBooks();if (bookID > 1) {if (numberOfBooks == 1) {book.update("DELETE FROM Books WHERE BookID =" + data);//for setting JTextField to nullremoveTextField.setText(null);}if (numberOfBooks > 1) {numberOfBooks -= 1;book.update("UPDATE Books SET NumberOfBooks =" + numberOfBooks + " WHERE BookID =" + data);//for setting JTextField to nullremoveTextField.setText(null);}}elseJOptionPane.showMessageDialog(null, "The BookID is wrong!", "Error", JOptionPane.ERROR_MESSAGE);}};runner.start();}//if there is a missing data, then display Message Dialogelse {JOptionPane.showMessageDialog(null, "Please, complete the information", "Warning", JOptionPane.WARNING_MESSAGE);}}});//for adding the action listener for the button to dispose the frameexitButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent ae) {dispose();}});//for setting the visible to truesetVisible(true);//show the internal framepack();}}RemoveMembers.java//import the packages for using the classes in them into the programimport javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;//for creating the North Panelprivate JPanel northPanel = new JPanel();//for creating the labelprivate JLabel title = new JLabel("MEMBER INFORMATION");//for creating the Center Panelprivate JPanel centerPanel = new JPanel();//for creating an Internal Panel in the center panelprivate JPanel removePanel = new JPanel();//for creating the labelprivate JLabel removeLabel = new JLabel(" Write the Member ID: ");//for creating the text fieldprivate JTextField removeTextField = new JTextField();//for creating string to store the dataprivate String data;//for creating an Internal Panel in the center panelprivate JPanel removeMemberPanel = new JPanel();//for creating the buttonprivate JButton removeButton = new JButton("Remove");//for creating the South Panelprivate JPanel southPanel = new JPanel();//for adding the buttonprivate JButton exitButton = new JButton("Exit");//create objects from another classes for using them in the ActionListenerprivate Members member;//for checking the information from the text fieldpublic boolean isCorrect() {if (!removeTextField.getText().equals("")) {data = removeTextField.getText();return true;}elsereturn false;}

//constructor of removeMemberspublic RemoveMembers() {//for setting the title for the internal framesuper("Remove Members", false, true, false, true);//for setting the iconsetFrameIcon(new ImageIcon(ClassLoader.getSystemResource("images/Delete16.gif")));//for getting the graphical user interface components display areaContainer cp = getContentPane();//for setting the layoutnorthPanel.setLayout(new FlowLayout(FlowLayout.CENTER));//for setting the fonttitle.setFont(new Font("Tahoma", Font.BOLD, 14));//for adding the labelnorthPanel.add(title);//for adding the panel to the containercp.add("North", northPanel);//for setting the layoutcenterPanel.setLayout(new BorderLayout());//for setting the layoutremovePanel.setLayout(new GridLayout(1, 2, 1, 1));//for adding the labelremovePanel.add(removeLabel);//for adding the text fieldremovePanel.add(removeTextField);//for adding the internal panel to the panelcenterPanel.add("Center", removePanel);//for setting the layoutremoveMemberPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));//for adding the buttonremoveMemberPanel.add(removeButton);//for addint the internal panel to the center panelcenterPanel.add("South", removeMemberPanel);//for setting the bordercenterPanel.setBorder(BorderFactory.createTitledBorder("Remove a member:"));//for adding the center panel to the containercp.add("Center", centerPanel);removeLabel.setFont(new Font("Tahoma", Font.BOLD, 11));removeTextField.setFont(new Font("Tahoma", Font.PLAIN, 11));exitButton.setFont(new Font("Tahoma", Font.BOLD, 11));removeButton.setFont(new Font("Tahoma", Font.BOLD, 11));//for setting the layoutsouthPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));//for adding the buttonsouthPanel.add(exitButton);//for setting the bordersouthPanel.setBorder(BorderFactory.createEtchedBorder());//for add the south panel to the containercp.add("South", southPanel);removeButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent ae) {//for checking if there is a missing informationif (isCorrect()) {Thread runner = new Thread() {public void run() {member = new Members();member.connection("SELECT * FROM Members WHERE MemberID = " + data);//for checking if the user borrowed any book form the libraryint numberOfBooks = member.getNumberOfBooks();if (numberOfBooks == 0) {member.update("DELETE FROM Members WHERE MemberID = " + data);//for setting the JTextField to nullremoveTextField.setText(null);}elseJOptionPane.showMessageDialog(null, "Book(s) borrowed by the member", "Warning", JOptionPane.WARNING_MESSAGE);}};runner.start();}//if there is a missing data, then display Message Dialogelse {JOptionPane.showMessageDialog(null, "Please, complete the information", "Warning", JOptionPane.WARNING_MESSAGE);}}});//for adding the action listener for the button to dispose the frameexitButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent ae) {dispose();}});//for setting the visible to truesetVisible(true);//show the internal framepack();}}

4.5 Snapshots of UI and Reports Login Screen:

Main Window:

Book Information:

List of Books:

Edit Books:

Remove Books:

Add Members:

Members List:

Edit Members:

Search Function:

Borrow Books:

Book Reservation:

CHAPTER 5FUTURE ENHANCEMENTS Extra and user defined security needs can be employed during request and response.

Records of students and admin activities can be maintained.

Another enhancement would be to add more modules like online library, course allocation to cover all information off the system.

Also, a release of API version is planned so the system can be integrated with other third-party applications. It will enhance the document management within other applications

CHAPTER 6LIMITATIONS All the details are in the hands of admin only.

Limited to offline only.

Limited to particular college only.

Number of server machines is assumed to be more with more number of users accessing the system. But if the user limit exceeds, it can slow down the server system and congest the network.

CHAPTER 7CONCLUSIONLibrary Management System leads to a better organization structure since the information management of the all the available books is well-structured and also leads to better as well as efficient utilization of resources.Library Management System can be used by education institutes to maintain the records of availability of books in the library easily. Achieving this objective is difficult using a manual system as the information is scattered, it can be redundant and collecting relevant information may be very time-consuming. All these problems are solved using this project.

CHAPTER 8BIBLIOGRAPHY J2 Complete Reference.

www.google.com.

www.wikipedia.com

www.w3schools.com

Head First PHP & MySQL by Lynn Beighley and Michael Morrison(OReilly)