IP Project: Library Management System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 111

LIBRARY MANAGEMENT SYSYTEM

Page 1 of 111

M.E.S INDIAN SCHOOL


DOHA,QATAR

Informatics Practices Project

LIBRARY MANAGEMENT SYSTEM


Completed & Submitted By:
SAMIHA ANTARA
XII K

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 2 of 111

BONAFIDE CERTIFICATE
Certified to be the bonafide record of the work done by
Master/Miss_________________________ of class XII ____
In the Computer Laboratory of M.E.S. Indian School, Doha-Qatar, during the
academic year___________________ She has performed _______assignments.

Date:_____________

Signature of Teacher in Charge


Name:__________________________

School Seal
Roll Number/ registration Number

Submitted for Annual / All India Senior School Certificate Practical Examination in Informatics Practices
________________ held at M.E.S. Indian School, Doha, Qatar on __________ .
Examiner (External)

Examiner (Internal)

Signature:_________________

Signature:________________

Name:____________________

Name:____________________

Designation:_______________

Designation:_______________

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Table of contents

Page 3 of 111

Page No.

1 Aim.6
2 Introduction: JAVA & MySQL7-9
3 Introduction....10-13
1.1 Problem Definition.......10
1.2 Objective & Scope.10-12
1.3 Proposed System12
1.4 Assumptions & Constraints12-13
1.5 System Requirements..13

Software Requirement Specification[SRS] & Design14-17


2.1 Introduction..14-15
Purpose
System overview
2.2 Overall description16-17
Product perspective
Product functions
User characteristics
Constraints, assumptions and dependencies

Specific requirements.18-24
3.1 Interface requirements18
3.2 Functional requirements18-19

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 4 of 111

3.3 Performance requirements19


3.4 Design constraints19
3.5 Database Schema20-21
3.6 Software System attributes..22
3.7 Detailed Life Cycle of the project22-24

Project Implementation25-107
4.1 Work Break down Structure.25
4.2 Code with reference to design.26-98
4.3 Snapshot of UI & Reports..99-107

Future Enhancements..108

Limitations.109

Conclusion..110

Bibliographies.111

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 5 of 111

ACKNOWLEDGEMENT
I extend my sincere thanks to my school :
M.E.S INDIAN SCHOOL, which provided me with the
opportunity to fulfill my wish and achieve my goal.
I would like to express deep debt to MRS. BLESSY MARY,
project guide for her vital suggestions, meticulous guidance and
constant motivation which went a long way in the successful
completion of this project.
I cannot move on without thanking my beloved principal
MR. A.P. SHASHIDHARAN, for creating the required academic
environment which made my task appreciable.
On a moral personal note, my deepest appreciation and gratitude
to my beloved parents, who have been an inspiration and have
provided me with unrelenting encouragement and support.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 6 of 111

AIM:
To develop an application based on
Library Management System.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 7 of 111

Introduction : JAVA

Java is a computer programming language that is concurrent, classbased, object-oriented, and specifically designed to have as few implementation dependencies as
possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning
that code that runs on one platform does not needto be recompiled to run on another. Java
applications are typically compiled to byte code that can run on any Java (JVM) regardless
of computer architecture. Java is, as of 2014, one of the most popular programming languages in
use, particularly for client-server web applications, with a reported 9 million developers. [10][11] Java
was originally developed by James Gosling at Sun Microsystems (which has since merged into
Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform.
The language derives much of its syntax from C and C++, but it has fewer low-level facilities than
either of them.
The original and reference implementation Java compilers, virtual machines, and class libraries were
originally released by Sun under proprietary licenses. As of May 2007, in compliance with the
specifications of the Java Community Process, Sun relicensed most of its Java technologies under
the GNU General Public License. Others have also developed alternative implementations of these
Sun technologies, such as the GNU Compiler for Java (byte code compiler), GNU Class
path (standard libraries), and Iced Tea-Web (browser plug-in for applets).

James Gosling, the creator of Java

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

There were five primary goals in the creation of the Java language:
1. It should be "simple, object-oriented and familiar"
2. It should be "robust and secure"
3. It should be "architecture-neutral and portable"
4. It should execute with "high performance"
5. It should be "interpreted, threaded, and dynamic"

Versions
Major release versions of Java, along with their release dates:

JDK 1.0 (January 21, 1996)

JDK 1.1 (February 19, 1997)

J2SE 1.2 (December 8, 1998)

J2SE 1.3 (May 8, 2000)

J2SE 1.4 (February 6, 2002)

J2SE 5.0 (September 30, 2004)

Java SE 6 (December 11, 2006)

Java SE 7 (July 28, 2011)

Java SE 8 (March 18, 2014)

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 8 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 9 of 111

MySQL
MySQL officially, but also called "My Sequel" is (as of March 2014) the world's second most widely
used open-source relational database management system (RDBMS). It is named after cofounder Michael Widenius's daughter, My. The SQL phrase stands for Structured Query Language.
The MySQL development project has made its source code available under the terms of the GNU
General Public License, as well as under a variety of proprietary agreements. MySQL was owned
and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned by Oracle
Corporation.
MySQL is a popular choice of database for use in web applications, and is a central component of
the widely used LAMP open source web application software stack (and other 'AMP' stacks). LAMP
is an acronym for "Linux, Apache, MySQL, Perl/PHP/Python." Free-software-open source projects
that require a full-featured database management system often use MySQL.
For proprietary use, several paid editions are available, and offer additional functionality.
Applications which use MySQL databases
include:TYPO3, MODx, Joomla, WordPress, phpBB, MyBB, Drupal and other software. MySQL is
also used in many high-profile, large-scale websites, including Google (though not for
searches), Facebook, Twitter, Flickr, and YouTube.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 10 of 111

1. INTRODUCTION
1.1 Problem Definition
TO DEVELOP A LIBRARY MANAGEMENT SYSTEM.
Library Management System can be used by educat ion inst itutes to maint ain t he
records of books easily. Achieving this objective is difficult using manual system as
the informat ion is scattered, can be redundant and collect ing relevant informat ion
may be very t ime 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 etc


1.2 Objective & Scope
Objective

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.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 11 of 111

Scope
Without 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 id

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 12 of 111

Existing System
According 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 System


Library 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.


Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 13 of 111

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): MySQL

Software 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

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 14 of 111

2. SOFTWARE REQUIREMENT SPECIFICATIONS


2.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

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 15 of 111

START

Login

Books

Members

Add Books

Add
Members

List All
Books

List
Available
Books

Search

Loan

Reserve

Borrow a
Book

Reserve a
Book

List All
Members

Return A
Book

Edit
Members

Issued
Book
Details

List
Borrowed
Books

Remove
Members

Edit Books

Member
Info

Remove
Books

STOP

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 16 of 111

2.2 Overall Description


Product 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 manner
Product 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

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 17 of 111

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.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 18 of 111

3. SPECIFIC REQUIREMENTS AND PROJECT ANALYSIS & DESIGN


3.1 Interface Requirements:
User Interface:
A software provides the front-end, i.e. the user interface.

Login

Admin
o Add Edit, Remove and Search Borrowers.
o Add Edit, Remove and Search Borrowed books.
o Add Edit, Remove and Search Books.
o Search and Preview due dates of the Books.
o Search and Preview Returned dates of the Books.
o Add Edit, Remove and Search Categories.
o Add and Remove Yearly Records.
o 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.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 19 of 111

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.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 20 of 111

3.5 Database Schema:


Books
Column

Type

CONSTRAINT

BookID

integer

Primary Key

Subject

varchar(20)

Not Null

Title

varchar(20)

Not Null

Author

varchar(20)

Not Null

Publisher

Varchar(20)

Not Null

Copyright

integer

Not Null

Edition

integer

Not Null

Pages

integer

Not Null

ISBN

Varchar(50)

Not Null

NumberOfBooks

Integer

Not Null

NumberOfAvailabeBooks

Integer

Not Null

NumberOfBorrowedBooks integer

Not Null

Library

Varchar(10)

Not Null

Available

integer

Not Null

ShelfNo

integer

Not Null

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 21 of 111

Borrow

Column

Type

CONSTRAINT

BookID

integer

Foreign Key

MemberID

varchar(20)

Foreign Key

DayOfBorrowed

varchar(20)

Not Null

DayOfReturn

varchar(20)

Not Null

Column

Type

CONSTRAINT

MemberID

integer

Primary Key

ID

integer

Not Null

Password

varchar(20)

Not Null

NAME

varchar(20)

Not Null

EMAIL

varchar(20)

Major

varchar(20)

Not Null

NumberOfBooks

integer

Not Null

Mony

integer

Not Null

Expired

datetime

Not Null

Members

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 22 of 111

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

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 23 of 111

Phases of Waterfall Model:

REQUIREMENT ANALYSIS
This 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.

DESIGN
Software 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. The
Design 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.
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 24 of 111

DEVELOPMENT
The 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.

CODING
The 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.

TESTING
Testing 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.

IMPLEMENTATION
After 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 IMPLEMENTATION
If 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.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 25 of 111

4. PROJECT IMPLEMENTATION
4.1 Work Breakdown Structure
Library Management
System

Books

Members

Search

Loan

Add

Add

Borrow

List All

List All

Return

Edit

Details

Available
Borrowed
Edit

Reserve

Remove
Info

Remove

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Help

About Us

LIBRARY MANAGEMENT SYSYTEM

4.2 Code with reference to design


AddBooks.java
//import the packages for using the classes in them into the program
import 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 = {
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 26 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 27 of 111

" 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() {
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 28 of 111

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();
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 29 of 111

//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));
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 30 of 111

}
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
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 31 of 111

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]);

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 32 of 111

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);
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 33 of 111

//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();
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 34 of 111

}
}
AddMembers.java
//import the packages for using the classes in them into the program
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class AddMembers extends JInternalFrame {
//for creating the North Panel
private JPanel northPanel = new JPanel();
//for creaing the North Label
private JLabel northLabel = new JLabel("MEMBER 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[7];
//for creating an array of String
private String[] informaionString = {" Member ID: ", " The Password: ", " Rewrite the
password: ",
" The Name: ", " E-MAIL: ", " Major:", " Expired: "};
//for creating an Internal Panel in the center panel
private JPanel informationTextFieldPanel = new JPanel();

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 35 of 111

//for creating an array of JTextField


private JTextField[] informationTextField = new JTextField[5];
//for creating an array of JPasswordField
private JPasswordField[] informationPasswordField = new JPasswordField[2];
//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 the 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 Members member;
//for creating an array of string to store the data
private String[] data;
//for checking the password
public 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;

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 36 of 111

return true;
}
//for checking the information from the text field
public 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();
}
else
return 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();
}
else
return false;
}
}
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 37 of 111

return true;
}
//for setting the array of JTextField & JPasswordField to null
public 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 addMembers
public AddMembers() {
//for setting the title for the internal frame
super("Add Members", 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

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 38 of 111

northLabel.setFont(new Font("Tahoma", Font.BOLD, 14));


//for adding the label to the panel
northPanel.add(northLabel);
//for adding the 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 member:"));
//for setting the layout
informationLabelPanel.setLayout(new GridLayout(7, 1, 1, 1));
//for setting the layout
informationTextFieldPanel.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 centerPanel
centerPanel.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));
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 39 of 111

}
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) {
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 40 of 111

//for checking if there is a missing information


if (isCorrect()) {
if (isPasswordCorrect()) {
Thread runner = new Thread() {
public void run() {
member = new Members();
//for checking if there is no same
information in the database
member.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 null
clearTextField();
}
else

JOptionPane.showMessageDialog(null, "Member is in the Library", "Error",


JOptionPane.ERROR_MESSAGE);
}
};
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 41 of 111

runner.start();
}
//if the password is wrong
else
JOptionPane.showMessageDialog(null, "the
passowrd is wrong", "Error", JOptionPane.ERROR_MESSAGE);
}
//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();
}
}
Books.java
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

//import the packages for using the classes in them into the program
import 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;
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 42 of 111

LIBRARY MANAGEMENT SYSYTEM

}
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;
}
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 43 of 111

LIBRARY MANAGEMENT SYSYTEM

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());
}
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 44 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 45 of 111

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) {
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 46 of 111

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());
}
}
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

}
Borrow.java
//import the packages for using the classes in them into the program
import 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() {
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 47 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 48 of 111

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();
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 49 of 111

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());
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

}
}
}
Login.java
import java.awt.EventQueue;
public class login extends javax.swing.JFrame {
public login() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GENBEGIN: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) {

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 50 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 51 of 111

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)
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 52 of 111

.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)
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 53 of 111

.addComponent(jButton1)))
.addContainerGap(81, Short.MAX_VALUE))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jTextField1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextField1ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST: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());
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 54 of 111

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);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {

new login().setVisible(true);
}
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

});
}
// 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 program
import 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);
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 55 of 111

LIBRARY MANAGEMENT SYSYTEM

// Throw a nice little title page up on the screen first


new 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 program
import 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() {
}
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 56 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 57 of 111

/*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;
}

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

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());
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 58 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 59 of 111

}
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());
}
}

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 60 of 111

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 program
import javax.swing.*;
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

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));

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 61 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 62 of 111

// 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 program
import 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;
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

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');
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 63 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 64 of 111

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]));
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 65 of 111

//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));
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 66 of 111

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 program
import 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;
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

public class PrintingBooks extends JInternalFrame implements Printable {


//for setting the connection and statement
private Connection connection = null;
private Statement statement = null;
private ResultSet resultset = null;

private String URL = "jdbc:mysql://localhost:3306/jlibrary";


//for creating the text area
private JTextArea textArea = new JTextArea();
//for creating the vector to use it in the print
private Vector lines;
public static final int TAB_SIZE = 5;
//constructor of JLibrary
public PrintingBooks(String query) {
super("Printing Books", false, true, false, true);
//for getting the graphical user interface components display area
Container cp = getContentPane();
//for setting the font
textArea.setFont(new Font("Tahoma", Font.PLAIN, 9));
//for adding the textarea to the container
cp.add(textArea);
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException ea) {
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 67 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 68 of 111

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();
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 69 of 111

}
catch (SQLException SQLe) {
System.out.println(SQLe.toString());
}
//for setting the visible to true
setVisible(true);
//to show the frame
pack();
}
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();
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 70 of 111

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();
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 71 of 111

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;

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 72 of 111

}
line2 += token;
}
v.add(line2);
}
return v;
}
}

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 73 of 111

ResultSetTableModel.java
import 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 status
private boolean connectedToDatabase = false;
// initialize resultSet and obtain its meta data object;
// determine number of rows
public ResultSetTableModel(String driver, String url, String query) throws
SQLException, ClassNotFoundException {
Class.forName(driver); // load database driver class
connection = DriverManager.getConnection(url,"root","pat123"); // connect to
database
// create Statement to query database
statement =
connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
connectedToDatabase = true; // update database connection status
setQuery(query); // set query and execute it
}

// get class that represents column type


Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 74 of 111

public Class getColumnClass(int column) throws IllegalStateException {


// ensure database connection is available
if (!connectedToDatabase) throw new IllegalStateException("Not Connected to
Database");
// determine Java class of column
try {
String className = metaData.getColumnClassName(column + 1);
return Class.forName(className); // return Class object that represents
className
}
// catch SQLExceptions and ClassNotFoundExceptions
catch (Exception exception) {
exception.printStackTrace();
}
// if problems occur above, assume type Object
return Object.class;
}
// get number of columns in ResultSet
public int getColumnCount() throws IllegalStateException {
// ensure database connection is available
if (!connectedToDatabase) throw new IllegalStateException("Not Connected to
Database");
// determine number of columns
try {
return metaData.getColumnCount();
}
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 75 of 111

// catch SQLExceptions and print error message


catch (SQLException sqlException) {
sqlException.printStackTrace();
}
// if problems occur above, return 0 for number of columns
return 0;
}
// get name of a particular column in ResultSet
public String getColumnName(int column) throws IllegalStateException {
// ensure database connection is available
if (!connectedToDatabase) throw new IllegalStateException("Not Connected to
Database");
// determine column name
try {
return metaData.getColumnName(column + 1);
}
// catch SQLExceptions and print error message
catch (SQLException sqlException) {
sqlException.printStackTrace();
}
// if problems, return empty string for column name
return "";
}

// return number of rows in ResultSet

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 76 of 111

public int getRowCount() throws IllegalStateException {


// ensure database connection is available
if (!connectedToDatabase) throw new IllegalStateException("Not Connected to
Database");
return numberOfRows;
}
// obtain value in particular row and column
public Object getValueAt(int row, int column) throws IllegalStateException {
// ensure database connection is available
if (!connectedToDatabase) throw new IllegalStateException("Not Connected to
Database");
// obtain a value at specified ResultSet row and column
try {
resultSet.absolute(row + 1);
return resultSet.getObject(column + 1);
}
// catch SQLExceptions and print error message
catch (SQLException sqlException) {
sqlException.printStackTrace();
}
// if problems, return empty string object
return "";
}

// set new database query string


public void setQuery(String query) throws SQLException, IllegalStateException {
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 77 of 111

// ensure database connection is available


if (!connectedToDatabase) throw new IllegalStateException("Not Connected to
Database");
// specify query and execute it
resultSet = statement.executeQuery(query);
// obtain meta data for ResultSet
metaData = resultSet.getMetaData();
// determine number of rows in ResultSet
resultSet.last(); // move to last row
numberOfRows = resultSet.getRow(); // get row number
fireTableStructureChanged(); // notify JTable that model has changed
}
// close Statement and Connection
public void disconnectFromDatabase() {
// close Statement and Connection
try {
statement.close();
connection.close();
}
// catch SQLExceptions and print error message
catch (SQLException sqlException) {
sqlException.printStackTrace();
}
// update database connection status
finally {

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

connectedToDatabase = false;
}
}
} // end class ResultSetTableModel
MembersInformation.java
//import the packages for using the classes in them into the program
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//for creating the North Panel
private JPanel northPanel = new JPanel();
//for creaing the North Label
private JLabel northLabel = new JLabel("MEMBER INFORMATION");
//for creating the Center Panel
private JPanel centerPanel = new JPanel();
//for creating the edit Panel
private JPanel memberIDPanel = new JPanel();
//for creating the edit information Panel
private JPanel memberIDInformationPanel = new JPanel();
//for creating the edit label panel
private JPanel memberIDInformationLabelPanel = new JPanel();
//for creating the edit textField panel
private JPanel memberIDInformationTextFieldPanel = new JPanel();
//for creating the edit button panel
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 78 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 79 of 111

private JPanel memberIDButtonPanel = new JPanel();


//for creating the label
private JLabel memberIDLabel = new JLabel("MemberID: ");
//for creating the textField
private JTextField memberIDTextField = new JTextField(25);
//for creating the button
private JButton memberIDButton = new JButton("OK");
//for creating the information Panel
private JPanel informationPanel = 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[7];
//for creating an array of String
private String[] informaionString = {" Member ID: ", " The Password: ", " Rewrite the
password: ",
" The Name: ", " E-MAIL: ", " Major:", " Expired: "};
//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[5];
//for creating an array of JPasswordField
private JPasswordField[] informationPasswordField = new JPasswordField[2];
//for creating an Internal Panel in the center panel
private JPanel InformationButtonPanel = new JPanel();

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 80 of 111

//for creating a button


private JButton fButton = new JButton(">");
//for creating the South Panel
private JPanel southPanel = new JPanel();
//for creating a button
private JButton exitButton = new JButton("Exit");
//create objects from another classes for using them in the ActionListener
private Members member;
//for creating an array of string to store the data
private String[] data;
//for checking the password
public 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 field
public boolean isCorrect() {
data = new String[6];
for (int i = 0; i < informationLabel.length; i++) {
if (i == 0) {
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 81 of 111

if (!informationTextField[i].getText().equals("")) {
data[i] = informationTextField[i].getText();
}
else
return 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();
}
else
return false;
}
}
return true;
}
//for checking the information from the text field
public boolean isEditCorrect() {
if (memberIDTextField.getText().equals(""))
return false;
return true;
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 82 of 111

}
//for setting the array of JTextField & JPasswordField to null
public 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 addMembers
public MembersInformation() {
//for setting the title for the internal frame
super("Members Information", false, true, false, true);
//for setting the icon
setFrameIcon(new
ImageIcon(ClassLoader.getSystemResource("images/Information16.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

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 83 of 111

northLabel.setFont(new Font("Tahoma", Font.BOLD, 14));


//for adding the label to the panel
northPanel.add(northLabel);
//for adding the panel to the container
cp.add("North", northPanel);
//for setting the layout
centerPanel.setLayout(new BorderLayout());
//for setting the layout
memberIDPanel.setLayout(new BorderLayout());
//for setting the border to the panel
memberIDPanel.setBorder(BorderFactory.createTitledBorder("MemberID: "));
//for setting the layout
memberIDInformationPanel.setLayout(new BorderLayout());
//for setting the layout
memberIDInformationLabelPanel.setLayout(new GridLayout(1, 1, 1, 1));
//for adding the label to the panel
memberIDInformationLabelPanel.add(memberIDLabel);
//for setting the font to the label
memberIDLabel.setFont(new Font("Tahoma", Font.BOLD, 11));
//for adding the editInformationLabelPanel to the editInformationLabel
memberIDInformationPanel.add("West", memberIDInformationLabelPanel);
//for setting the layout
memberIDInformationTextFieldPanel.setLayout(new GridLayout(1, 1, 1, 1));
//for adding the textField to the panel
memberIDInformationTextFieldPanel.add(memberIDTextField);
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 84 of 111

//for setting the font to the textField


memberIDTextField.setFont(new Font("Tahoma", Font.PLAIN, 11));
//for adding the editInformationTextField to the editInformationPanel
memberIDInformationPanel.add("East", memberIDInformationTextFieldPanel);
//for adding the editInformationPanel to the editPanel
memberIDPanel.add("North", memberIDInformationPanel);
//for setting the layout
memberIDButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
//for adding the button to the panel
memberIDButtonPanel.add(memberIDButton);
//for setting the fonr to the button
memberIDButton.setFont(new Font("Tahoma", Font.BOLD, 11));
//for adding the editInformationButtonPanel to the editPanel
memberIDPanel.add("Center", memberIDButtonPanel);
//for adding the editPanel to the centerPanel
centerPanel.add("North", memberIDPanel);
//for setting the layout
informationPanel.setLayout(new BorderLayout());
//for setting the border to the panel
informationPanel.setBorder(BorderFactory.createTitledBorder("Edit a member:
"));
//for setting the layout
informationLabelPanel.setLayout(new GridLayout(7, 1, 1, 1));
//for setting the layout
informationTextFieldPanel.setLayout(new GridLayout(7, 1, 1, 1));

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 85 of 111

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 centerPanel
informationPanel.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);
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 86 of 111

}
}
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 frame
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
//for setting the visible to true
setVisible(true);
//show the internal frame
pack();
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

}
}
RemoveBooks.java
//import the packages for using the classes in them into the program
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//for creating the North Panel
private JPanel northPanel = new JPanel();
//for creating the label
private JLabel title = 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 removePanel = new JPanel();
//for creating the label
private JLabel removeLabel = new JLabel(" Write the Book ID: ");
//for creating the text field
private JTextField removeTextField = new JTextField();
//for creating string to store the data
private String data;
//for creating an Internal Panel in the center panel
private JPanel removeMemberPanel = new JPanel();
//for creating the button
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 87 of 111

LIBRARY MANAGEMENT SYSYTEM

private JButton removeButton = new JButton("Remove");


//for creating the South Panel
private JPanel southPanel = new JPanel();
//for adding the button
private JButton exitButton = new JButton("Exit");
//create objects from another classes for using them in the ActionListener
private Books book;
//for checking the information from the text field
public boolean isCorrect() {
if (!removeTextField.getText().equals("")) {
data = removeTextField.getText();
return true;
}
else
return false;
}

//constructor of removeBooks
public RemoveBooks() {
//for setting the title for the internal frame
super("Remove Books", false, true, false, true);
//for setting the icon
setFrameIcon(new
ImageIcon(ClassLoader.getSystemResource("images/Delete16.gif")));
//for getting the graphical user interface components display area

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 88 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 89 of 111

Container cp = getContentPane();
//for setting the layout
northPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
//for setting the font
title.setFont(new Font("Tahoma", Font.BOLD, 14));
//for adding the label
northPanel.add(title);
//for adding the panel to the container
cp.add("North", northPanel);
//for setting the layout
centerPanel.setLayout(new BorderLayout());
//for setting the layout
removePanel.setLayout(new GridLayout(1, 2, 1, 1));
//for adding the label
removePanel.add(removeLabel);
//for adding the text field
removePanel.add(removeTextField);
//for adding the internal panel to the panel
centerPanel.add("Center", removePanel);

//for setting the layout


removeMemberPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
//for adding the button
removeMemberPanel.add(removeButton);
//for addint the internal panel to the center panel
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 90 of 111

centerPanel.add("South", removeMemberPanel);
//for setting the border
centerPanel.setBorder(BorderFactory.createTitledBorder("Remove a book:"));
//for adding the center panel to the container
cp.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 layout
southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
//for adding the button
southPanel.add(exitButton);
//for setting the border
southPanel.setBorder(BorderFactory.createEtchedBorder());
//for add the south panel to the container
cp.add("South", southPanel);
removeButton.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 getting the information
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 91 of 111

book.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 null

removeTextField.setText(null);
}
if (numberOfBooks > 1) {
numberOfBooks -= 1;
book.update("UPDATE
Books SET NumberOfBooks =" + numberOfBooks + " WHERE BookID =" + data);
//for setting JTextField to null

removeTextField.setText(null);
}
}
else

JOptionPane.showMessageDialog(null, "The BookID is wrong!", "Error",


JOptionPane.ERROR_MESSAGE);
}
};
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 92 of 111

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
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
//for setting the visible to true
setVisible(true);
//show the internal frame
pack();
}
}
RemoveMembers.java
//import the packages for using the classes in them into the program
import javax.swing.*;
import java.awt.*;

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//for creating the North Panel
private JPanel northPanel = new JPanel();
//for creating the label
private JLabel title = new JLabel("MEMBER INFORMATION");
//for creating the Center Panel
private JPanel centerPanel = new JPanel();
//for creating an Internal Panel in the center panel
private JPanel removePanel = new JPanel();
//for creating the label
private JLabel removeLabel = new JLabel(" Write the Member ID: ");
//for creating the text field
private JTextField removeTextField = new JTextField();
//for creating string to store the data
private String data;
//for creating an Internal Panel in the center panel
private JPanel removeMemberPanel = new JPanel();
//for creating the button
private JButton removeButton = new JButton("Remove");
//for creating the South Panel
private JPanel southPanel = new JPanel();
//for adding the button
private JButton exitButton = new JButton("Exit");
//create objects from another classes for using them in the ActionListener
Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 93 of 111

LIBRARY MANAGEMENT SYSYTEM

private Members member;


//for checking the information from the text field
public boolean isCorrect() {
if (!removeTextField.getText().equals("")) {
data = removeTextField.getText();
return true;
}
else
return false;
}

//constructor of removeMembers
public RemoveMembers() {
//for setting the title for the internal frame
super("Remove Members", false, true, false, true);
//for setting the icon
setFrameIcon(new
ImageIcon(ClassLoader.getSystemResource("images/Delete16.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
title.setFont(new Font("Tahoma", Font.BOLD, 14));
//for adding the label

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 94 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 95 of 111

northPanel.add(title);
//for adding the panel to the container
cp.add("North", northPanel);
//for setting the layout
centerPanel.setLayout(new BorderLayout());
//for setting the layout
removePanel.setLayout(new GridLayout(1, 2, 1, 1));
//for adding the label
removePanel.add(removeLabel);
//for adding the text field
removePanel.add(removeTextField);
//for adding the internal panel to the panel
centerPanel.add("Center", removePanel);
//for setting the layout
removeMemberPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
//for adding the button
removeMemberPanel.add(removeButton);
//for addint the internal panel to the center panel
centerPanel.add("South", removeMemberPanel);
//for setting the border
centerPanel.setBorder(BorderFactory.createTitledBorder("Remove a member:"));
//for adding the center panel to the container
cp.add("Center", centerPanel);
removeLabel.setFont(new Font("Tahoma", Font.BOLD, 11));
removeTextField.setFont(new Font("Tahoma", Font.PLAIN, 11));
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 96 of 111

exitButton.setFont(new Font("Tahoma", Font.BOLD, 11));


removeButton.setFont(new Font("Tahoma", Font.BOLD, 11));
//for setting the layout
southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
//for adding the button
southPanel.add(exitButton);
//for setting the border
southPanel.setBorder(BorderFactory.createEtchedBorder());
//for add the south panel to the container
cp.add("South", southPanel);
removeButton.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() {
member = new Members();
member.connection("SELECT * FROM
Members WHERE MemberID = " + data);
//for checking if the user borrowed any book
form the library
int numberOfBooks =
member.getNumberOfBooks();
if (numberOfBooks == 0) {
member.update("DELETE FROM
Members WHERE MemberID = " + data);
//for setting the JTextField to null
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 97 of 111

removeTextField.setText(null);
}
else

JOptionPane.showMessageDialog(null, "Book(s) borrowed by the member", "Warning",


JOptionPane.WARNING_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
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
//for setting the visible to true
setVisible(true);
//show the internal frame
Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

pack();
}
}

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 98 of 111

LIBRARY MANAGEMENT SYSYTEM

4.3 Screen shots


Login Screen:

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 99 of 111

LIBRARY MANAGEMENT SYSYTEM

Main Window:

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 100 of 111

LIBRARY MANAGEMENT SYSYTEM

Book Information:

List of Books:

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 101 of 111

LIBRARY MANAGEMENT SYSYTEM

Edit Books:

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 102 of 111

LIBRARY MANAGEMENT SYSYTEM

Remove Books:

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 103 of 111

LIBRARY MANAGEMENT SYSYTEM

Add Members:

Members List:

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 104 of 111

LIBRARY MANAGEMENT SYSYTEM

Edit Members:

Search Function:

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 105 of 111

LIBRARY MANAGEMENT SYSYTEM

Borrow Books:

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 106 of 111

LIBRARY MANAGEMENT SYSYTEM

Book Reservation:

Prepared by Samiha Antara & Hiba Fathima..Class XII K

Page 107 of 111

LIBRARY MANAGEMENT SYSYTEM

Page 108 of 111

5. FUTURE ENHANCEMENTS

Extra and user defined security needs can be employed during request and

Records of students and admin activities can be maintained.

Another enhancement would be to add more modules like online library, course

response.

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

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 109 of 111

6. LIMITATIONS

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.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 110 of 111

7. CONCLUSION
Library Management System leads to a better organizat ion 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 educat ion inst itutes to maintain t he
records of availabilit y of books in the library easily. Achieving this object ive is
difficult using a manual system as the informat ion is scattered, it can be redundant
and collect ing relevant informat ion may be very t ime-consuming. All these
problems are solved using this project.

Prepared by Samiha Antara & Hiba Fathima..Class XII K

LIBRARY MANAGEMENT SYSYTEM

Page 111 of 111

8.BIBLIOGRAPHY

www.scribd.com
www.google.com
www.wikipedia.com

Prepared by Samiha Antara & Hiba Fathima..Class XII K

You might also like