You are on page 1of 178

Library Management System

Project Report

B.Sc. Computer Science

Submitted By:-

Negi Manmohan Singh Gautam Singh


R.no 14

Department Of Computer Science


Mumbai University
ACKNOWLEDGEMENT

Apart from the efforts of team, the success of any project depends largely on
the encouragement and guidelines of many others. We take this opportunity
to express our gratitude to the people who have been instrumental in the
successful completion of this project. The completion of any inter-
disciplinary project depends upon cooperation, co-ordination and combined
efforts of several sources of knowledge. We are eternally grateful to our
teacher Arti Debnath for her even willingness to give us valuable advice
and direction under which we executed this project. Her constant guidance
and willingness to share her vast knowledge made us understand this project
and its manifestations in great depths and helped us to complete the assigned
tasks.

Negi Manmohan Singh


R.no.14
CERTIFICATE

This is to certify that project report entitled "Library Management


System" is the work carried out Negi Manmohan Singh student of
B.Sc. Computer Science VI Semester, Nes Ratnam College of arts
,science and commerce, University of Mumbai under the
supervision of Arti Debnath, Department of Computer Science.
This report has not been submitted to any other
organization/institution for the award any other degree/diploma.

Project Guide
Arti Debnath
ABSTRACT

A Library Management System is a system that is used to


maintain the records of the library. It contains work like the number
of the available books, the number of books issued, the number of
books to return or renew. It helps to maintain a database that is
useful to enter new books and records of books borrowed by the
members with the respective submission dates. It will reduce the
manual work done by the librarian to maintain the record of the
library. It allows maintaining the resources in a more operative
manner that will help to save the time. It is also convenient for the
librarian to manage the process of books allocation. It is useful for
students as well as a librarian to keep the constant track of the
availability of all books in a library.
Table of Contents

S.no Topic Signature


1. Problem statement
2. Process model
3. Software requirement
specification (SRS)
5. Use Case Diagram
6. Use Case Description
7. ER Diagram
8. Sample Screenshots
9. Conclusion
Problem Statement
A college library management is a project that manages and stores
books information electronically according to student’s needs. The
system helps both students and library manager to keep a constant
track of all the books available in the library. It allows both the
admin and the student to search for the desired book. It becomes
necessary for colleges to keep a continuous check on the books
issued and returned and even calculate fine. This task if carried out
manually will be tedious and includes chances of mistakes. These
errors are avoided by allowing the system to keep track of
information such as issue date, last date to return the book and even
fine information and thus there is no need to keep manual track of
this information which thereby avoids chances of mistakes.
Thus, this system reduces manual work to a great extent allows
smooth flow of library activities by removing chances of errors in
the details.
PROCESS MODEL

Library Management System follows INCREMENTAL


MODEL because initially software requirements are
reasonably well defined but the overall scope of development
effort is a purely linear process. There may be other
requirements of the user which will be known later. So, those
requirements can the implemented and delivered in the
following next increments. Our project is a short term
project of 3 months and 3 weeks only and staffing available
is also low (3 persons).
Chapter 1
Introduction

1.1 PURPOSE
1.2 SCOPE
1.3 DEFINITIONS, ACRONYMS,
and ABBREVIATIONS
1.4 REFERENCES
1.5 OVERVIEW
1.1 PURPOSE
A library management system can help you seamlessly transition
from manually managed libraries to automated libraries, making
them more efficient and effective. The library management
system’s primary role is to securely keep all data on materials
discovered in a library in a cloud data storage. The purpose of
this project is to computerize all details regarding patient details
and hospital details

1.2 SCOPE
The critical functions of cataloging and circulation of books is
done automatically by the library management system software.
Entry of new books, deletion of old books and updating of the
member and book database becomes simple. The books
borrowed, returned, lost or misplaced can be tracked by the
system.
1.3 DEFINITIONS, ACRONYMS, and
ABBREVIATIONS

The critical functions of cataloging and circulation of books is


done automatically by the library management system software.
Entry of new books, deletion of old books and updating of the
member and book database becomes simple. The books
borrowed, returned, lost or misplaced can be tracked by the
system.

➢ Log in - Logging in Existing User


➢ Student Registration - add’s Student’s information
➢ Add new books- add’s new books information
➢ Issue Books – Issues book to student
➢ ReturnDetails – Show’s Books Borrowed by
student
➢ Books History – Show’s Books available
1.4 REFERENCES

Geeks for Geeks


W3 schools
Code Wars
Freecode stamp
Code academy
1.5 Advantages and disadvantages
of Lms

Advantages

• The system automates the manual procedure of managing


Library activities.
• Librarian can view their Student records and details easily.
• It Show’s Books detail and ReturnDetails
• The system is convenient and flexible to be used.
• It saves their time, efforts, money and resources.

Disadvantages

•Requires large database.


• The admin has to manually keep updating the information by
entering the details in the system
. • Need Internet connection.
Chapter 2
Software Requirements
Specification

2.1.1 System Interfaces

❖ User Interfaces
● This section provides a detailed description of all
inputs into and outputs from the system. It also
gives a description of the hardware, software and
communication interfaces and provides basic
prototypes of the user interface.
● The protocol used shall be HTTP.
● The Port number used will be 80.
● There shall be logical address of the system in
IPv4 format.
❖ Hardware Interface
▪ Laptop/Desktop PC-Purpose of this is to give
information when Student’s or admin See’s
information about Books, Available and
ReturnDetails . To perform such Action it
need very efficient computer otherwise due to
that reason Student’s have to wait for a long
time to get what they ask for.
▪ Wi-Fi router - Wi-Fi router is used to for
internetwork operations inside of a Library
and simply data transmission from pc’s to
sever.

❖ Software Interfaces
▪ JDK 1.8 - Java is fast, secure, and reliable.
From laptops to data centers, game consoles to
scientific supercomputers, cell phones to the
Internet,
▪ Mysql server - Database connectivity and
management
▪ OS Windows 7/8/8.1- Very user friendly and
common OS
▪ JRE 1.8 - JAVA Runtime Environment for
run Java Application and System
2.1.2 System Specifications
2.1.2.1 H/W Requirement
Core i3 processor
8 GB Ram.
20 GB of hard disk space in terminal machines
1TB hard disk space in Server Machine
2.1.2.2 S/W Requirement
Windows 7 or above operating system
JRE 1.8
Mysql server
User
Case Diagram:
User Case Description :

2.1 Administration Module:-

This is the main module in the proposed project. The administrator


can read and write information about any member such as patient,
doctors and staff of the hospital. They can also update, create and
delete the record of members as requirement and implementation
plan.

2.2 Login Page:

In this page we have to fields username and password. When we enter


incorrect username and password it will show a popup message
Incorrect Username or Password. If we enter correct username or
password we will move to next page. It having one more button for
exit this application.

2.3 Main Layer Page:

After login this one is first page. In this page we have seven button
and each button having different functionality.In this page there is
an arrow button which is used to change position of other buttons.

2.4 Student Registration:

In this page we have to register Student Name,Class,Division in our


database and having two buttons first one is used to save details and
second one is used close this page.
2.5 Add New Books:

In this page , admin can add new books to the System .

2.6 Book Details:

In this page we can see all the details of the books available in the
library.It also have a button to add new book this page.

2.7 Issue Details:

In this page we can see Issued book details to user by searching


student id. If ID does not exist it will show error message.

2.8 Issue Book:

In this page we can Issue books to particular Student.

2.9 Return Book:

In this page Admin


ER Diagram :
Database :
MYSQL COMMANDS:
1. Create Database library;
2. Use library;
3. Create table books(BookId
varchar(100)
Primarykey,Bookname
varchar(100),AuthorName
varchar(100),Stream
varchar(100),Class
varchar(100),Available
varchar(100));
4. Create table issue(StudentId
varchar(100),StudentName
varchar(100),BookId varchar(100),
BookName varchar(100),
Address varchar(100),IssueDate
varchar(100),SStream
varchar(100),SClass varchar(100));
5. Create table returndetail(StudentId
varchar(100),StudentName
varchar(100),BookId
varchar(100),BookName
varchar(100) ,IssuedOn
varchar(100),ReturnDate
varchar(100),PRIMARY KEY
(StudentId));
6. Create table student(StudentId
varchar(100) primary key,
StudentName varchar(100),Stream
varchar(100),Class
varchar(100),Address
varchar(100));
Coding Phase:
Login.java:
import javax.swing.JFrame;

import javax.swing.JOptionPane;

/*

* To change this license header, choose License Headers in


Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

/**

* @author gtmsn

*/

public class Login extends javax.swing.JFrame {

/**

* Creates new form Login

*/
public Login() {

initComponents();

setExtendedState(JFrame.MAXIMIZED_BOTH);

/**

* This method is called from within the constructor to


initialize the form.

* WARNING: Do NOT modify this code. The content of this


method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated


Code">

private void initComponents() {

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField();

jPasswordField1 = new javax.swing.JPasswordField();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();


jLabel3 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_
ON_CLOSE);

setUndecorated(true);

getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jLabel1.setText("Username");

getContentPane().add(jLabel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(520, 380, -1,
30));

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jLabel2.setText("Password");

getContentPane().add(jLabel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(520, 420, 80,
40));

jTextField1.setBackground(new java.awt.Color(255, 255,


204));
jTextField1.setFont(new java.awt.Font("Tahoma", 1, 14));
// NOI18N

getContentPane().add(jTextField1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(650, 390, 400, -
1));

jPasswordField1.setBackground(new java.awt.Color(255,
255, 204));

jPasswordField1.setFont(new java.awt.Font("Tahoma", 1,
14)); // NOI18N

getContentPane().add(jPasswordField1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(650, 430, 400, -
1));

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jButton1.setIcon(new
javax.swing.ImageIcon("C:\\Users\\gtmsn\\OneDrive\\Docum
ents\\NetBeansProjects\\Library Management System\\Icon
1\\login.png")); // NOI18N

jButton1.setText("Login");

jButton1.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

}
});

getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(650, 480, -1, -
1));

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jButton2.setIcon(new
javax.swing.ImageIcon("C:\\Users\\gtmsn\\OneDrive\\Docum
ents\\NetBeansProjects\\Library Management System\\Icon
1\\red-x-mark-transparent-background-3.png")); // NOI18N

jButton2.setText("Close");

jButton2.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(960, 480, -1, -
1));

jLabel3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Login.jpg"))); //
NOI18N
getContentPane().add(jLabel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 1430, -1));

pack();

}// </editor-fold>

private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if(jTextField1.getText().equals("admin") &&
jPasswordField1.getText().equals("admin"))

setVisible(false);

new MainLayer().setVisible(true);

else

JOptionPane.showMessageDialog(null,"Incorrect
Username or Password");

private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

System.exit(0);
}

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and


feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available,


stay with the default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfe
el/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(jav
a.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(jav
a.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(jav
a.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException
ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(jav
a.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);

}
});

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JPasswordField jPasswordField1;

private javax.swing.JTextField jTextField1;

// End of variables declaration

}
Main Layer.java:
public class MainLayer extends javax.swing.JFrame {

public MainLayer() {

initComponents();

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated


Code">

private void initComponents() {

jLabel1 = new javax.swing.JLabel();

jLabel4 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

jButton5 = new javax.swing.JButton();

jButton6 = new javax.swing.JButton();

jButton7 = new javax.swing.JButton();

jButton8 = new javax.swing.JButton();

jLabel6 = new javax.swing.JLabel();


jLabel7 = new javax.swing.JLabel();

jLabel8 = new javax.swing.JLabel();

jLabel9 = new javax.swing.JLabel();

jLabel10 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_
ON_CLOSE);

setBackground(new java.awt.Color(255, 255, 255));

setUndecorated(true);

getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

jLabel1.setFont(new java.awt.Font("Footlight MT Light", 0,


56)); // NOI18N

jLabel1.setForeground(new java.awt.Color(51, 153, 255));

jLabel1.setText("RATNAM LIBRARY");

getContentPane().add(jLabel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(480, 30, -1, -1));

getContentPane().add(jLabel4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(80, 180, -1, -1));

getContentPane().add(jLabel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(600, 150, 200, -
1));
getContentPane().add(jLabel5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(1020, 170, -1, -
1));

jButton2.setBackground(new java.awt.Color(0, 102, 102));

jButton2.setFont(new java.awt.Font("Tahoma", 1, 48)); //


NOI18N

jButton2.setForeground(new java.awt.Color(255, 255,


255));

jButton2.setText("Issue Book");

jButton2.addActionListener(new
java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent


evt) {

jButton2ActionPerformed(evt);

});

getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 520, -1, -1));

jButton3.setBackground(new java.awt.Color(0, 102, 102));

jButton3.setFont(new java.awt.Font("Tahoma", 1, 48)); //


NOI18N

jButton3.setForeground(new java.awt.Color(255, 255,


255));
jButton3.setText("Return Book");

jButton3.addActionListener(new
java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent


evt) {

jButton3ActionPerformed(evt);

});

getContentPane().add(jButton3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(960, 520, -1, -1));

jButton4.setBackground(new java.awt.Color(0, 102, 102));

jButton4.setFont(new java.awt.Font("Tahoma", 0, 24)); //


NOI18N

jButton4.setForeground(new java.awt.Color(255, 255,


255));

jButton4.setText("Add New Books");

jButton4.addActionListener(new
java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent


evt) {

jButton4ActionPerformed(evt);

});
getContentPane().add(jButton4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(450, 650, -1, -1));

jButton5.setBackground(new java.awt.Color(0, 102, 102));

jButton5.setFont(new java.awt.Font("Tahoma", 0, 24)); //


NOI18N

jButton5.setForeground(new java.awt.Color(255, 255,


255));

jButton5.setText("Student Registration");

jButton5.addActionListener(new
java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent


evt) {

jButton5ActionPerformed(evt);

});

getContentPane().add(jButton5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(600, 720, -1, -1));

jButton6.setBackground(new java.awt.Color(0, 102, 102));

jButton6.setFont(new java.awt.Font("Tahoma", 0, 24)); //


NOI18N

jButton6.setForeground(new java.awt.Color(255, 255,


255));

jButton6.setText("Issued Book Details");


jButton6.addActionListener(new
java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent


evt) {

jButton6ActionPerformed(evt);

});

getContentPane().add(jButton6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(810, 650, -1, -1));

jButton7.setBackground(new java.awt.Color(0, 102, 102));

jButton7.setFont(new java.awt.Font("Tahoma", 1, 48)); //


NOI18N

jButton7.setForeground(new java.awt.Color(255, 255,


255));

jButton7.setText("Book Details");

jButton7.addActionListener(new
java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent


evt) {

jButton7ActionPerformed(evt);

});

getContentPane().add(jButton7, new
org.netbeans.lib.awtextra.AbsoluteConstraints(100, 520, -1, -1));
jButton8.setFont(new java.awt.Font("Tahoma", 1, 14)); //
NOI18N

jButton8.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/exit.png"))); //
NOI18N

jButton8.setText("LOG OUT");

jButton8.addActionListener(new
java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent


evt) {

jButton8ActionPerformed(evt);

});

getContentPane().add(jButton8, new
org.netbeans.lib.awtextra.AbsoluteConstraints(1207, 698, -1, -
1));

getContentPane().add(jLabel6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

jLabel7.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Book
Details.png"))); // NOI18N

getContentPane().add(jLabel7, new
org.netbeans.lib.awtextra.AbsoluteConstraints(70, 120, -1, -1));
jLabel8.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Issue
Book.png"))); // NOI18N

getContentPane().add(jLabel8, new
org.netbeans.lib.awtextra.AbsoluteConstraints(610, 140, -1, -1));

jLabel9.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Return
Books.png"))); // NOI18N

getContentPane().add(jLabel9, new
org.netbeans.lib.awtextra.AbsoluteConstraints(1020, 180, -1, -
1));

jLabel10.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/books-1281581
(1) (1).png"))); // NOI18N

getContentPane().add(jLabel10, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

pack();

}// </editor-fold>

private void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

AddNewBook anb=new AddNewBook();

anb.setVisible(true);
this.setVisible(false);

private void
jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

RegisterStudent r=new RegisterStudent();

r.setVisible(true);

this.setVisible(false);

private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

IssueBook ib=new IssueBook();

ib.setVisible(true);

this.setVisible(false);

private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

ReturnBook rb=new ReturnBook();

rb.setVisible(true);

this.setVisible(false);

}
private void
jButton6ActionPerformed(java.awt.event.ActionEvent evt) {

IssuedBooks ibs=new IssuedBooks();

ibs.setVisible(true);

this.setVisible(false);

private void
jButton7ActionPerformed(java.awt.event.ActionEvent evt) {

BookDetails bd=new BookDetails();

bd.setVisible(true);

this.setVisible(false);

private void
jButton8ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

setVisible(false);

new Login().setVisible(true);

public static void main(String args[]) {


/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and


feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available, stay


with the default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfe
el/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(AddNewBook.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(AddNewBook.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(AddNewBook.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException
ex) {

java.util.logging.Logger.getLogger(AddNewBook.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);

//</editor-fold>

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new MainLayer().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;


private javax.swing.JButton jButton6;

private javax.swing.JButton jButton7;

private javax.swing.JButton jButton8;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel10;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JLabel jLabel9;

// End of variables declaration

}
Issue Book:
import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import javax.swing.JOptionPane;

import java.text.SimpleDateFormat;

import java.util.Date;

public class IssueBook extends javax.swing.JFrame {

Connection con;

Statement stmt;

ResultSet rs;

String query;

Date date=new Date();

SimpleDateFormat format=new SimpleDateFormat("dd-MM-


yyyy");
String checkAvailability,SName,Address,SStream,SClass;

/**

* Creates new form ReturnBook

*/

public IssueBook() {

initComponents();

/**

* This method is called from within the constructor to


initialize the form.

* WARNING: Do NOT modify this code. The content of this


method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated


Code">

private void initComponents() {

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

t1 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();

t2 = new javax.swing.JTextField();

jLabel4 = new javax.swing.JLabel();

t3 = new javax.swing.JTextField();

jLabel5 = new javax.swing.JLabel();

t4 = new javax.swing.JTextField();

jLabel6 = new javax.swing.JLabel();

t5 = new javax.swing.JTextField();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

jButton5 = new javax.swing.JButton();

jButton6 = new javax.swing.JButton();

jButton7 = new javax.swing.JButton();

t6 = new javax.swing.JTextField();

jLabel7 = new javax.swing.JLabel();

jLabel8 = new javax.swing.JLabel();

jLabel9 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_
ON_CLOSE);
setUndecorated(true);

addWindowListener(new java.awt.event.WindowAdapter() {

public void
windowActivated(java.awt.event.WindowEvent evt) {

OnCreate(evt);

});

getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

jLabel1.setFont(new java.awt.Font("Lucida Handwriting",


0, 36)); // NOI18N

jLabel1.setForeground(new java.awt.Color(0, 102, 102));

jLabel1.setText("Issue Book");

getContentPane().add(jLabel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(590, 180, -1, -
1));

jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel2.setText("Student Id");

getContentPane().add(jLabel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(500, 240, -1, -
1));
t1.setFont(new java.awt.Font("Tahoma", 0, 14)); //
NOI18N

t1.addActionListener(new java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

t1ActionPerformed(evt);

});

t1.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(java.awt.event.KeyEvent evt) {

t1KeyReleased(evt);

});

getContentPane().add(t1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(630, 240, 130, -
1));

jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel3.setText("Student Name");

getContentPane().add(jLabel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(500, 290, -1, -
1));
t2.setFont(new java.awt.Font("Tahoma", 0, 14)); //
NOI18N

t2.setEnabled(false);

getContentPane().add(t2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(630, 290, 261, -
1));

jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel4.setText("Book Id");

getContentPane().add(jLabel4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(500, 350, -1, -
1));

t3.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

t3.addActionListener(new java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

t3ActionPerformed(evt);

});

t3.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(java.awt.event.KeyEvent evt) {

t3KeyReleased(evt);
}

});

getContentPane().add(t3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(630, 340, 129, -
1));

jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel5.setText("Book name");

getContentPane().add(jLabel5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(500, 440, -1, -
1));

t4.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

t4.setEnabled(false);

getContentPane().add(t4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(630, 440, 261, -
1));

jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel6.setText("Issue Date");

getContentPane().add(jLabel6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(500, 490, -1, -
1));
t5.setFont(new java.awt.Font("Tahoma", 0, 14)); //
NOI18N

t5.setEnabled(false);

t5.addActionListener(new java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

t5ActionPerformed(evt);

});

getContentPane().add(t5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(630, 490, 133, -
1));

jButton1.setBackground(new java.awt.Color(0, 102, 102));

jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jButton1.setForeground(new java.awt.Color(255, 255,


255));

jButton1.setText("Issue");

jButton1.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);
}

});

getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(590, 540, -1, -
1));

jButton2.setBackground(new java.awt.Color(204, 0, 0));

jButton2.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jButton2.setForeground(new java.awt.Color(255, 255,


255));

jButton2.setText("Cancel");

jButton2.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(760, 540, -1, -
1));

jButton3.setBackground(new java.awt.Color(0, 102, 102));


jButton3.setFont(new java.awt.Font("Tahoma", 0, 12)); //
NOI18N

jButton3.setForeground(new java.awt.Color(255, 255,


255));

jButton3.setText("Home");

jButton3.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

getContentPane().add(jButton3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(500, 610, -1, -
1));

jButton4.setBackground(new java.awt.Color(0, 102, 102));

jButton4.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton4.setForeground(new java.awt.Color(255, 255,


255));

jButton4.setText("Book Details");

jButton4.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);

});

getContentPane().add(jButton4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(610, 610, -1, -
1));

jButton5.setBackground(new java.awt.Color(0, 102, 102));

jButton5.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton5.setForeground(new java.awt.Color(255, 255,


255));

jButton5.setText("Return Book");

jButton5.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton5ActionPerformed(evt);

});

getContentPane().add(jButton5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(760, 610, -1, -
1));

jButton6.setBackground(new java.awt.Color(0, 102, 102));


jButton6.setFont(new java.awt.Font("Tahoma", 0, 12)); //
NOI18N

jButton6.setForeground(new java.awt.Color(255, 255,


255));

jButton6.setText("Issued Book Details");

jButton6.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton6ActionPerformed(evt);

});

getContentPane().add(jButton6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(920, 610, -1, -
1));

jButton7.setBackground(new java.awt.Color(0, 102, 102));

jButton7.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton7.setForeground(new java.awt.Color(255, 255,


255));

jButton7.setText("Student Registration");

jButton7.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);

});

getContentPane().add(jButton7, new
org.netbeans.lib.awtextra.AbsoluteConstraints(310, 610, -1, -
1));

t6.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

t6.setEnabled(false);

getContentPane().add(t6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(630, 390, 48, -
1));

jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel7.setText("Available");

getContentPane().add(jLabel7, new
org.netbeans.lib.awtextra.AbsoluteConstraints(500, 390, -1, -
1));

getContentPane().add(jLabel8, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

jLabel9.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/new
back.jpg"))); // NOI18N
getContentPane().add(jLabel9, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

pack();

}// </editor-fold>

private void t1ActionPerformed(java.awt.event.ActionEvent


evt) {

// TODO add your handling code here:

private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

MainLayer mn=new MainLayer();

mn.setVisible(true);

this.setVisible(false);

private void OnCreate(java.awt.event.WindowEvent evt) {

// TODO add your handling code here:

private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if(t2.getText().equals(""))

JOptionPane.showMessageDialog(this,"PLS REGISTER
YOUR NAME ");

else

try

connect();

query="select * from books where


BookId='"+t3.getText()+"';";

query="select *from student where


StudentId='"+t1.getText()+"';";

rs=stmt.executeQuery(query);

rs.next();

if(t6.getText().equals("YES"))

query="insert into issue


values('"+t1.getText()+"','"+t2.getText()+"','"+t3.getText()+"','"+t4.
getText()+"','"+Address+"','"+t5.getText()+"','"+SStream+"','"+SClas
s+"');";

stmt.executeUpdate(query);

JOptionPane.showMessageDialog(this,"Book
with id = "+t3.getText()+" has been issued to "+t2.getText());
query="update books set Available='NO' where
BookId='"+t3.getText()+"';";

stmt.executeUpdate(query);

if(t6.getText().equals("NO"))

JOptionPane.showMessageDialog(this,"Book
with this id is not available currently");

if(t6.getText().equals(""))

JOptionPane.showMessageDialog(this,"There
is no book in the library with this id");

t4.setText("");

t1.setText("");

t2.setText("");

t3.setText("");

t6.setText("");

disconnect();
}

catch(SQLException e)

if(e.getErrorCode()==1062)

JOptionPane.showMessageDialog(this,"A
student can only get a single book from library at a time ");

private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

MainLayer mn=new MainLayer();

mn.setVisible(true);

this.setVisible(false);

private void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

BookDetails bd=new BookDetails();


bd.setVisible(true);

this.setVisible(false);

private void
jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

ReturnBook rb=new ReturnBook();

rb.setVisible(true);

this.setVisible(false);

private void
jButton7ActionPerformed(java.awt.event.ActionEvent evt) {

RegisterStudent r=new RegisterStudent();

r.setVisible(true);

this.setVisible(false);

private void
jButton6ActionPerformed(java.awt.event.ActionEvent evt) {

IssuedBooks ibs=new IssuedBooks();

ibs.setVisible(true);

this.setVisible(false);
}

private void t1KeyReleased(java.awt.event.KeyEvent evt) {

try

connect();

query="select * from student where


StudentId='"+t1.getText()+"';";

rs=stmt.executeQuery(query);

if(rs.next())

SName=rs.getString("StudentName");

Address=rs.getString("Address");

SStream=rs.getString("Stream");

SClass=rs.getString("Class");

t2.setText(SName);

else

t2.setText("");

disconnect();

catch(Exception e)

{
System.out.println(e);

t5.setText(format.format(date));

private void t3KeyReleased(java.awt.event.KeyEvent evt) {

try

connect();

query="select * from books where


BookId='"+t3.getText()+"';";

rs=stmt.executeQuery(query);

if(rs.next())

t6.setText(rs.getString("Available"));

t4.setText(rs.getString("BookName"));

else

t6.setText("");

t4.setText("");

disconnect();
}

catch(Exception e)

System.out.println(e);

private void t5ActionPerformed(java.awt.event.ActionEvent


evt) {

// TODO add your handling code here:

private void t3ActionPerformed(java.awt.event.ActionEvent


evt) {

// TODO add your handling code here:

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */


//<editor-fold defaultstate="collapsed" desc=" Look and
feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available,


stay with the default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfe
el/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(ReturnBook.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(ReturnBook.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {


java.util.logging.Logger.getLogger(ReturnBook.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException
ex) {

java.util.logging.Logger.getLogger(ReturnBook.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 IssueBook().setVisible(true);

});

public void connect()

try

Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(

"jdbc:mysql://localhost:3306/library?useSSL=false&autoRecon
nect=true","root","root");

stmt=con.createStatement();

catch(Exception e)

System.out.println(e);

JOptionPane.showMessageDialog(this,"connection
error");

public void disconnect()

try

con.close();

catch(Exception e)

{}

}
// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;

private javax.swing.JButton jButton6;

private javax.swing.JButton jButton7;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JLabel jLabel9;

private javax.swing.JTextField t1;

private javax.swing.JTextField t2;

private javax.swing.JTextField t3;

private javax.swing.JTextField t4;


private javax.swing.JTextField t5;

private javax.swing.JTextField t6;

// End of variables declaration

Book Details:

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

public class BookDetails extends javax.swing.JFrame {

Connection con;

Statement stmt;

ResultSet rs;
String query;

String BId,Bname,Bauthor,strm,cls,avl;

/**

* Creates new form BookDetails

*/

public BookDetails() {

initComponents();

/**

* This method is called from within the constructor to


initialize the form.

* WARNING: Do NOT modify this code. The content of this


method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated


Code">
private void initComponents() {

b1 = new javax.swing.ButtonGroup();

r1 = new javax.swing.JRadioButton();

r2 = new javax.swing.JRadioButton();

c1 = new javax.swing.JComboBox<>();

c2 = new javax.swing.JComboBox<>();

txt1 = new javax.swing.JTextField();

jScrollPane2 = new javax.swing.JScrollPane();

table = new javax.swing.JTable();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

jButton5 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_
ON_CLOSE);

setUndecorated(true);
getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

b1.add(r1);

r1.setFont(new java.awt.Font("Tahoma", 0, 13)); //


NOI18N

r1.setText("Search by Book Name");

r1.addActionListener(new java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

r1ActionPerformed(evt);

});

getContentPane().add(r1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(300, 230, -1, -
1));

b1.add(r2);

r2.setFont(new java.awt.Font("Tahoma", 0, 13)); //


NOI18N

r2.setText("Search By Class");

r2.addActionListener(new java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

r2ActionPerformed(evt);
}

});

getContentPane().add(r2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(300, 280, -1, -
1));

c1.setForeground(new java.awt.Color(204, 0, 0));

c1.setModel(new
javax.swing.DefaultComboBoxModel<>(new String[] { "Select
Stream", "Science", "Commerce", "Arts" }));

c1.setEnabled(false);

c1.addActionListener(new java.awt.event.ActionListener()
{

public void
actionPerformed(java.awt.event.ActionEvent evt) {

c1ActionPerformed(evt);

});

getContentPane().add(c1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(480, 270, 185,
29));

c2.setForeground(new java.awt.Color(204, 0, 0));

c2.setModel(new
javax.swing.DefaultComboBoxModel<>(new String[] { "Select
Class" }));
c2.setEnabled(false);

c2.addActionListener(new java.awt.event.ActionListener()
{

public void
actionPerformed(java.awt.event.ActionEvent evt) {

c2ActionPerformed(evt);

});

getContentPane().add(c2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(760, 270, 155,
29));

txt1.setFont(new java.awt.Font("Tahoma", 0, 15)); //


NOI18N

txt1.setForeground(new java.awt.Color(204, 0, 0));

txt1.setEnabled(false);

txt1.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

txt1ActionPerformed(evt);

});

txt1.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(java.awt.event.KeyEvent evt) {


txt1KeyReleased(evt);

});

getContentPane().add(txt1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(480, 230, 185, -
1));

table.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

"Book Id", "Book Name", "Author", "Sream", "Class",


"Available"

));

table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL
_COLUMNS);

jScrollPane2.setViewportView(table);

if (table.getColumnModel().getColumnCount() > 0) {

table.getColumnModel().getColumn(0).setPreferredWidth(40);

table.getColumnModel().getColumn(1).setPreferredWidth(210);
table.getColumnModel().getColumn(2).setPreferredWidth(150);

table.getColumnModel().getColumn(3).setPreferredWidth(40);

table.getColumnModel().getColumn(4).setPreferredWidth(40);

table.getColumnModel().getColumn(5).setPreferredWidth(40);

getContentPane().add(jScrollPane2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(300, 330, 778,
262));

jButton1.setBackground(new java.awt.Color(0, 102, 102));

jButton1.setForeground(new java.awt.Color(255, 255,


255));

jButton1.setText("Add a New Book ");

jButton1.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});
getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(750, 230, 160,
26));

jButton2.setBackground(new java.awt.Color(0, 102, 102));

jButton2.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton2.setForeground(new java.awt.Color(255, 255,


255));

jButton2.setText("Home");

jButton2.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(350, 620, 94, -
1));

jButton3.setBackground(new java.awt.Color(0, 102, 102));

jButton3.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton3.setForeground(new java.awt.Color(255, 255,


255));
jButton3.setText("Issue Book");

jButton3.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

getContentPane().add(jButton3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 620, 105, -
1));

jButton4.setBackground(new java.awt.Color(0, 102, 102));

jButton4.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton4.setForeground(new java.awt.Color(255, 255,


255));

jButton4.setText("Return Book");

jButton4.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton4ActionPerformed(evt);

});
getContentPane().add(jButton4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(700, 620, -1, -
1));

jButton5.setBackground(new java.awt.Color(0, 102, 102));

jButton5.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton5.setForeground(new java.awt.Color(255, 255,


255));

jButton5.setText("Issued Book Details");

jButton5.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton5ActionPerformed(evt);

});

getContentPane().add(jButton5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(870, 620, -1, -
1));

jLabel1.setFont(new java.awt.Font("Lucida Handwriting",


0, 36)); // NOI18N

jLabel1.setForeground(new java.awt.Color(0, 102, 102));

jLabel1.setText("Book Details");
getContentPane().add(jLabel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(580, 180, -1, -
1));

getContentPane().add(jLabel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

jLabel3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/new
back.jpg"))); // NOI18N

getContentPane().add(jLabel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

pack();

}// </editor-fold>

private void r1ActionPerformed(java.awt.event.ActionEvent


evt) {

c1.disable();c2.disable();

txt1.enable();

private void
txt1ActionPerformed(java.awt.event.ActionEvent evt) {

}
private void r2ActionPerformed(java.awt.event.ActionEvent
evt) {

txt1.disable();

c1.enable();

private void c2ActionPerformed(java.awt.event.ActionEvent


evt) {

try

connect();

query="select * from books where


Stream='"+c1.getSelectedItem()+"' and
Class='"+c2.getSelectedItem()+"';";

rs=stmt.executeQuery(query);

DefaultTableModel
model=(DefaultTableModel)table.getModel();

model.setRowCount(0);

while(rs.next())

Object[] row =
{rs.getString("BookId"),rs.getString("BookName"),rs.getString("A
uthorName"),rs.getString("Stream"),rs.getString("Class"),rs.getSt
ring("Available")};

model.addRow(row);

disconnect();

catch(Exception e)

System.out.println(e);

private void c1ActionPerformed(java.awt.event.ActionEvent


evt) {

c2.enable();

if(c1.getSelectedItem()=="Science")

c2.removeAllItems();

c2.addItem("Select
Class");c2.addItem("FYBScCS");c2.addItem("SYBScCS");c2.addIt
em("TYBScCS");

}
if(c1.getSelectedItem()=="Arts")

c2.removeAllItems();

c2.addItem("Select
Class");c2.addItem("FYBA");c2.addItem("SYBA");c2.addItem("TY
BA");

if(c1.getSelectedItem()=="Commerce")

c2.removeAllItems();

c2.addItem("Select
Class");c2.addItem("FYBCom");c2.addItem("SYBCom");c2.addIte
m("TYBCom");

private void txt1KeyReleased(java.awt.event.KeyEvent evt) {

DefaultTableModel
model=(DefaultTableModel)table.getModel();

model.setRowCount(0);

String txt=txt1.getText();

if(txt.equals(""))

System.out.println("");

else
{

try

connect();

query="select * from books where


BookName='"+txt1.getText()+"';";

rs=stmt.executeQuery(query);

while(rs.next())

Object[] row =
{rs.getString("BookId"),rs.getString("BookName"),rs.getString("A
uthorName"),rs.getString("Stream"),rs.getString("Class"),rs.getSt
ring("Available")};

model.addRow(row);

disconnect();

catch(Exception e)

System.out.println(e);

}
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

AddNewBook anb=new AddNewBook();

anb.setVisible(true);

this.setVisible(false);

private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

MainLayer mn=new MainLayer();

mn.setVisible(true);

this.dispose();

private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

IssueBook ib=new IssueBook();

ib.setVisible(true);

this.setVisible(false);

private void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

ReturnBook rb=new ReturnBook();


rb.setVisible(true);

this.setVisible(false);

private void
jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

IssuedBooks ibs=new IssuedBooks();

ibs.setVisible(true);

this.setVisible(false);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and


feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available,


stay with the default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfe
el/plaf.html

*/
try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(BookDetails.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(BookDetails.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(BookDetails.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException
ex) {

java.util.logging.Logger.getLogger(BookDetails.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 BookDetails().setVisible(true);

});

public void connect()

try

Class.forName("com.mysql.jdbc.Driver");

con=DriverManager.getConnection(

"jdbc:mysql://localhost:3306/library?useSSL=false&autoRecon
nect=true","root","root");

stmt=con.createStatement();

catch(Exception e)

{
System.out.println(e);

JOptionPane.showMessageDialog(this,"connection
error");

public void disconnect()

try

con.close();

catch(Exception e)

{}

// Variables declaration - do not modify

private javax.swing.ButtonGroup b1;

private javax.swing.JComboBox<String> c1;

private javax.swing.JComboBox<String> c2;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;


private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JScrollPane jScrollPane2;

private javax.swing.JRadioButton r1;

private javax.swing.JRadioButton r2;

private javax.swing.JTable table;

private javax.swing.JTextField txt1;

// End of variables declaration

}
Register Student:

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

public class BookDetails extends javax.swing.JFrame {

Connection con;

Statement stmt;

ResultSet rs;

String query;

String BId,Bname,Bauthor,strm,cls,avl;
/**

* Creates new form BookDetails

*/

public BookDetails() {

initComponents();

/**

* This method is called from within the constructor to


initialize the form.

* WARNING: Do NOT modify this code. The content of this


method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated


Code">

private void initComponents() {

b1 = new javax.swing.ButtonGroup();

r1 = new javax.swing.JRadioButton();
r2 = new javax.swing.JRadioButton();

c1 = new javax.swing.JComboBox<>();

c2 = new javax.swing.JComboBox<>();

txt1 = new javax.swing.JTextField();

jScrollPane2 = new javax.swing.JScrollPane();

table = new javax.swing.JTable();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

jButton5 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_
ON_CLOSE);

setUndecorated(true);

getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

b1.add(r1);
r1.setFont(new java.awt.Font("Tahoma", 0, 13)); //
NOI18N

r1.setText("Search by Book Name");

r1.addActionListener(new java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

r1ActionPerformed(evt);

});

getContentPane().add(r1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(300, 230, -1, -
1));

b1.add(r2);

r2.setFont(new java.awt.Font("Tahoma", 0, 13)); //


NOI18N

r2.setText("Search By Class");

r2.addActionListener(new java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

r2ActionPerformed(evt);

});
getContentPane().add(r2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(300, 280, -1, -
1));

c1.setForeground(new java.awt.Color(204, 0, 0));

c1.setModel(new
javax.swing.DefaultComboBoxModel<>(new String[] { "Select
Stream", "Science", "Commerce", "Arts" }));

c1.setEnabled(false);

c1.addActionListener(new java.awt.event.ActionListener()
{

public void
actionPerformed(java.awt.event.ActionEvent evt) {

c1ActionPerformed(evt);

});

getContentPane().add(c1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(480, 270, 185,
29));

c2.setForeground(new java.awt.Color(204, 0, 0));

c2.setModel(new
javax.swing.DefaultComboBoxModel<>(new String[] { "Select
Class" }));

c2.setEnabled(false);
c2.addActionListener(new java.awt.event.ActionListener()
{

public void
actionPerformed(java.awt.event.ActionEvent evt) {

c2ActionPerformed(evt);

});

getContentPane().add(c2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(760, 270, 155,
29));

txt1.setFont(new java.awt.Font("Tahoma", 0, 15)); //


NOI18N

txt1.setForeground(new java.awt.Color(204, 0, 0));

txt1.setEnabled(false);

txt1.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

txt1ActionPerformed(evt);

});

txt1.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(java.awt.event.KeyEvent evt) {

txt1KeyReleased(evt);
}

});

getContentPane().add(txt1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(480, 230, 185, -
1));

table.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

"Book Id", "Book Name", "Author", "Sream", "Class",


"Available"

));

table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL
_COLUMNS);

jScrollPane2.setViewportView(table);

if (table.getColumnModel().getColumnCount() > 0) {

table.getColumnModel().getColumn(0).setPreferredWidth(40);

table.getColumnModel().getColumn(1).setPreferredWidth(210);
table.getColumnModel().getColumn(2).setPreferredWidth(150);

table.getColumnModel().getColumn(3).setPreferredWidth(40);

table.getColumnModel().getColumn(4).setPreferredWidth(40);

table.getColumnModel().getColumn(5).setPreferredWidth(40);

getContentPane().add(jScrollPane2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(300, 330, 778,
262));

jButton1.setBackground(new java.awt.Color(0, 102, 102));

jButton1.setForeground(new java.awt.Color(255, 255,


255));

jButton1.setText("Add a New Book ");

jButton1.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});
getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(750, 230, 160,
26));

jButton2.setBackground(new java.awt.Color(0, 102, 102));

jButton2.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton2.setForeground(new java.awt.Color(255, 255,


255));

jButton2.setText("Home");

jButton2.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(350, 620, 94, -
1));

jButton3.setBackground(new java.awt.Color(0, 102, 102));

jButton3.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton3.setForeground(new java.awt.Color(255, 255,


255));
jButton3.setText("Issue Book");

jButton3.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

getContentPane().add(jButton3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 620, 105, -
1));

jButton4.setBackground(new java.awt.Color(0, 102, 102));

jButton4.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton4.setForeground(new java.awt.Color(255, 255,


255));

jButton4.setText("Return Book");

jButton4.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton4ActionPerformed(evt);

});
getContentPane().add(jButton4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(700, 620, -1, -
1));

jButton5.setBackground(new java.awt.Color(0, 102, 102));

jButton5.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton5.setForeground(new java.awt.Color(255, 255,


255));

jButton5.setText("Issued Book Details");

jButton5.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton5ActionPerformed(evt);

});

getContentPane().add(jButton5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(870, 620, -1, -
1));

jLabel1.setFont(new java.awt.Font("Lucida Handwriting",


0, 36)); // NOI18N

jLabel1.setForeground(new java.awt.Color(0, 102, 102));

jLabel1.setText("Book Details");
getContentPane().add(jLabel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(580, 180, -1, -
1));

getContentPane().add(jLabel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

jLabel3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/new
back.jpg"))); // NOI18N

getContentPane().add(jLabel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

pack();

}// </editor-fold>

private void r1ActionPerformed(java.awt.event.ActionEvent


evt) {

c1.disable();c2.disable();

txt1.enable();

private void
txt1ActionPerformed(java.awt.event.ActionEvent evt) {

}
private void r2ActionPerformed(java.awt.event.ActionEvent
evt) {

txt1.disable();

c1.enable();

private void c2ActionPerformed(java.awt.event.ActionEvent


evt) {

try

connect();

query="select * from books where


Stream='"+c1.getSelectedItem()+"' and
Class='"+c2.getSelectedItem()+"';";

rs=stmt.executeQuery(query);

DefaultTableModel
model=(DefaultTableModel)table.getModel();

model.setRowCount(0);

while(rs.next())

Object[] row =
{rs.getString("BookId"),rs.getString("BookName"),rs.getString("A
uthorName"),rs.getString("Stream"),rs.getString("Class"),rs.getSt
ring("Available")};

model.addRow(row);

disconnect();

catch(Exception e)

System.out.println(e);

private void c1ActionPerformed(java.awt.event.ActionEvent


evt) {

c2.enable();

if(c1.getSelectedItem()=="Science")

c2.removeAllItems();

c2.addItem("Select
Class");c2.addItem("FYBScCS");c2.addItem("SYBScCS");c2.addIt
em("TYBScCS");

}
if(c1.getSelectedItem()=="Arts")

c2.removeAllItems();

c2.addItem("Select
Class");c2.addItem("FYBA");c2.addItem("SYBA");c2.addItem("TY
BA");

if(c1.getSelectedItem()=="Commerce")

c2.removeAllItems();

c2.addItem("Select
Class");c2.addItem("FYBCom");c2.addItem("SYBCom");c2.addIte
m("TYBCom");

private void txt1KeyReleased(java.awt.event.KeyEvent evt) {

DefaultTableModel
model=(DefaultTableModel)table.getModel();

model.setRowCount(0);

String txt=txt1.getText();

if(txt.equals(""))

System.out.println("");

else
{

try

connect();

query="select * from books where


BookName='"+txt1.getText()+"';";

rs=stmt.executeQuery(query);

while(rs.next())

Object[] row =
{rs.getString("BookId"),rs.getString("BookName"),rs.getString("A
uthorName"),rs.getString("Stream"),rs.getString("Class"),rs.getSt
ring("Available")};

model.addRow(row);

disconnect();

catch(Exception e)

System.out.println(e);

}
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

AddNewBook anb=new AddNewBook();

anb.setVisible(true);

this.setVisible(false);

private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

MainLayer mn=new MainLayer();

mn.setVisible(true);

this.dispose();

private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

IssueBook ib=new IssueBook();

ib.setVisible(true);

this.setVisible(false);

private void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

ReturnBook rb=new ReturnBook();


rb.setVisible(true);

this.setVisible(false);

private void
jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

IssuedBooks ibs=new IssuedBooks();

ibs.setVisible(true);

this.setVisible(false);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and


feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available,


stay with the default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfe
el/plaf.html

*/
try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(BookDetails.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(BookDetails.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(BookDetails.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException
ex) {

java.util.logging.Logger.getLogger(BookDetails.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 BookDetails().setVisible(true);

});

public void connect()

try

Class.forName("com.mysql.jdbc.Driver");

con=DriverManager.getConnection(

"jdbc:mysql://localhost:3306/library?useSSL=false&autoRecon
nect=true","root","root");

stmt=con.createStatement();

catch(Exception e)

{
System.out.println(e);

JOptionPane.showMessageDialog(this,"connection
error");

public void disconnect()

try

con.close();

catch(Exception e)

{}

// Variables declaration - do not modify

private javax.swing.ButtonGroup b1;

private javax.swing.JComboBox<String> c1;

private javax.swing.JComboBox<String> c2;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;


private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JScrollPane jScrollPane2;

private javax.swing.JRadioButton r1;

private javax.swing.JRadioButton r2;

private javax.swing.JTable table;

private javax.swing.JTextField txt1;

// End of variables declaration

}
Return Book:

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.swing.JOptionPane;

public class ReturnBook extends javax.swing.JFrame {

Connection con;

Statement stmt;

ResultSet rs;

String query;
Date date=new Date();

SimpleDateFormat format=new SimpleDateFormat("dd-MM-


yyyy");

/**

* Creates new form ReturnBook

*/

public ReturnBook() {

initComponents();

/**

* This method is called from within the constructor to


initialize the form.

* WARNING: Do NOT modify this code. The content of this


method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated


Code">

private void initComponents() {

jLabel1 = new javax.swing.JLabel();


jLabel2 = new javax.swing.JLabel();

t1 = new javax.swing.JTextField();

jLabel3 = new javax.swing.JLabel();

t2 = new javax.swing.JTextField();

jLabel4 = new javax.swing.JLabel();

t3 = new javax.swing.JTextField();

jLabel5 = new javax.swing.JLabel();

t4 = new javax.swing.JTextField();

jLabel6 = new javax.swing.JLabel();

t6 = new javax.swing.JTextField();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

jButton5 = new javax.swing.JButton();

jButton6 = new javax.swing.JButton();

jLabel7 = new javax.swing.JLabel();

t5 = new javax.swing.JTextField();

jLabel8 = new javax.swing.JLabel();

jLabel9 = new javax.swing.JLabel();


setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_
ON_CLOSE);

setUndecorated(true);

getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

jLabel1.setFont(new java.awt.Font("Lucida Handwriting",


0, 36)); // NOI18N

jLabel1.setForeground(new java.awt.Color(0, 102, 102));

jLabel1.setText("Return Book");

getContentPane().add(jLabel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(560, 170, -1, -
1));

jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel2.setText("Student Id");

getContentPane().add(jLabel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 240, -1, -
1));

t1.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

t1.addActionListener(new java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {

t1ActionPerformed(evt);

});

t1.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(java.awt.event.KeyEvent evt) {

t1KeyReleased(evt);

});

getContentPane().add(t1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(690, 230, 118, -
1));

jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel3.setText("Student Name");

getContentPane().add(jLabel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 290, -1, -
1));

t2.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

t2.setEnabled(false);
getContentPane().add(t2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(690, 280, 207, -
1));

jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel4.setText("Book Id");

getContentPane().add(jLabel4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 330, -1, -
1));

t3.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

t3.setEnabled(false);

getContentPane().add(t3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(690, 330, 122, -
1));

jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel5.setText("Book name");

getContentPane().add(jLabel5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 390, -1, -
1));

t4.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N
t4.setEnabled(false);

getContentPane().add(t4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(690, 390, 302, -
1));

jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel6.setText("Return Date");

getContentPane().add(jLabel6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 490, -1, -
1));

t6.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

t6.setEnabled(false);

getContentPane().add(t6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(690, 490, 127, -
1));

jButton1.setBackground(new java.awt.Color(0, 102, 102));

jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jButton1.setForeground(new java.awt.Color(255, 255,


255));

jButton1.setText("Return");
jButton1.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(550, 530, -1, -
1));

jButton2.setBackground(new java.awt.Color(204, 0, 0));

jButton2.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jButton2.setForeground(new java.awt.Color(255, 255,


255));

jButton2.setText("Cancel");

jButton2.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});
getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(730, 530, -1, -
1));

jButton3.setBackground(new java.awt.Color(0, 102, 102));

jButton3.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton3.setForeground(new java.awt.Color(255, 255,


255));

jButton3.setText("Home");

jButton3.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

getContentPane().add(jButton3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(440, 600, -1, -
1));

jButton4.setBackground(new java.awt.Color(0, 102, 102));

jButton4.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton4.setForeground(new java.awt.Color(255, 255,


255));
jButton4.setText("Book Details");

jButton4.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton4ActionPerformed(evt);

});

getContentPane().add(jButton4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(550, 600, -1, -
1));

jButton5.setBackground(new java.awt.Color(0, 102, 102));

jButton5.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton5.setForeground(new java.awt.Color(255, 255,


255));

jButton5.setText("Issue Book");

jButton5.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton5ActionPerformed(evt);

});
getContentPane().add(jButton5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(730, 600, -1, -
1));

jButton6.setBackground(new java.awt.Color(0, 102, 102));

jButton6.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton6.setForeground(new java.awt.Color(255, 255,


255));

jButton6.setText("Issued Book Details");

jButton6.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton6ActionPerformed(evt);

});

getContentPane().add(jButton6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(870, 600, -1, -
1));

jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel7.setText("Issued On");
getContentPane().add(jLabel7, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 450, -1, -
1));

t5.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

t5.setEnabled(false);

getContentPane().add(t5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(690, 440, 127, -
1));

getContentPane().add(jLabel8, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

jLabel9.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/new
back.jpg"))); // NOI18N

getContentPane().add(jLabel9, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

pack();

}// </editor-fold>

private void t1ActionPerformed(java.awt.event.ActionEvent


evt) {

// TODO add your handling code here:

}
private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

MainLayer mn=new MainLayer();

mn.setVisible(true);

this.setVisible(false);

private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

MainLayer mn=new MainLayer();

mn.setVisible(true);

this.setVisible(false);

private void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

BookDetails bd=new BookDetails();

bd.setVisible(true);

this.setVisible(false);

private void
jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
IssueBook ib=new IssueBook();

ib.setVisible(true);

this.setVisible(false);

private void
jButton6ActionPerformed(java.awt.event.ActionEvent evt) {

IssuedBooks ibs=new IssuedBooks();

ibs.setVisible(true);

this.setVisible(false);

private void t1KeyReleased(java.awt.event.KeyEvent evt) {

try

connect();

query="select * from issue where


StudentId='"+t1.getText()+"';";

rs=stmt.executeQuery(query);

int i=0;

while(rs.next())

i++;
t2.setText(rs.getString("StudentName"));

t3.setText(rs.getString("BookId"));

t4.setText(rs.getString("BookName"));

t5.setText(rs.getString("IssueDate"));

disconnect();

if(i==0)

t2.setText("");

t3.setText("");

t4.setText("");

t5.setText("");

catch(Exception e)

System.out.println(e);

t6.setText(format.format(date));

private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try

connect();

query="select * from issue where


StudentId='"+t1.getText()+"';";

rs=stmt.executeQuery(query);

if(rs.next())

query="insert into returndetail


values('"+t1.getText()+"','";

query+=t2.getText()+"','"+t3.getText()+"','"+t4.getText()+"','"+t5.g
etText()+"','"+t6.getText()+"');";

stmt.executeUpdate(query);

query="delete from issue where


StudentId='"+t1.getText()+"';";

stmt.executeUpdate(query);

query="update books set Available='YES' where


BookId='"+t3.getText()+"';";

stmt.executeUpdate(query);

disconnect();

JOptionPane.showMessageDialog(this,"Thank you!
visit again");

t4.setText("");
t1.setText("");

t2.setText("");

t3.setText("");

t5.setText("");

else

JOptionPane.showMessageDialog(this,"No book is
issued on this id currently");

catch(SQLException e)

JOptionPane.showMessageDialog(this,e);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */


//<editor-fold defaultstate="collapsed" desc=" Look and
feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available,


stay with the default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfe
el/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(ReturnBook.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(ReturnBook.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {


java.util.logging.Logger.getLogger(ReturnBook.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException
ex) {

java.util.logging.Logger.getLogger(ReturnBook.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 ReturnBook().setVisible(true);

});

public void connect()

try

Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(

"jdbc:mysql://localhost:3306/library?useSSL=false&autoRecon
nect=true","root","root");

stmt=con.createStatement();

catch(Exception e)

System.out.println(e);

JOptionPane.showMessageDialog(this,"connection
error");

public void disconnect()

try

con.close();

catch(Exception e)

{}

}
// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;

private javax.swing.JButton jButton6;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JLabel jLabel9;

private javax.swing.JTextField t1;

private javax.swing.JTextField t2;

private javax.swing.JTextField t3;

private javax.swing.JTextField t4;

private javax.swing.JTextField t5;


private javax.swing.JTextField t6; }

Add New Book:


import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

import java.sql.Statement;

import javax.swing.JOptionPane;

public class AddNewBook extends javax.swing.JFrame {

Connection con;

Statement stmt;

String query;

/**

* Creates new form AddNewBook

*/

public AddNewBook() {

initComponents();

}
/**

* This method is called from within the constructor to


initialize the form.

* WARNING: Do NOT modify this code. The content of this


method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated


Code">

private void initComponents() {

jLabel1 = new javax.swing.JLabel();

txt2 = new javax.swing.JTextField();

jLabel2 = new javax.swing.JLabel();

txt3 = new javax.swing.JTextField();

jLabel3 = new javax.swing.JLabel();

txt4 = new javax.swing.JTextField();

jLabel4 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

c3 = new javax.swing.JComboBox<>();
c4 = new javax.swing.JComboBox<>();

jLabel6 = new javax.swing.JLabel();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

jButton5 = new javax.swing.JButton();

jButton6 = new javax.swing.JButton();

jButton7 = new javax.swing.JButton();

jLabel7 = new javax.swing.JLabel();

jLabel8 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_
ON_CLOSE);

setUndecorated(true);

getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jLabel1.setText("Book Id");

getContentPane().add(jLabel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(350, 230, -1, -
1));
txt2.setFont(new java.awt.Font("Tahoma", 0, 14)); //
NOI18N

getContentPane().add(txt2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(470, 230, 160, -
1));

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jLabel2.setText("Book Name");

getContentPane().add(jLabel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(350, 290, -1, -
1));

txt3.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

getContentPane().add(txt3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(470, 280, 160, -
1));

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jLabel3.setText("Author");

getContentPane().add(jLabel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(350, 330, -1, -
1));
txt4.setFont(new java.awt.Font("Tahoma", 0, 14)); //
NOI18N

getContentPane().add(txt4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(470, 320, 160, -
1));

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jLabel4.setText("Stream");

getContentPane().add(jLabel4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(350, 380, -1, -
1));

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jLabel5.setText("Class");

getContentPane().add(jLabel5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(350, 430, -1, -
1));

jButton1.setBackground(new java.awt.Color(0, 102, 102));

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jButton1.setForeground(new java.awt.Color(255, 255,


255));

jButton1.setText("Add");
jButton1.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(350, 480, 116, -
1));

jButton2.setBackground(new java.awt.Color(204, 0, 0));

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

jButton2.setForeground(new java.awt.Color(255, 255,


255));

jButton2.setText("Cancel");

jButton2.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});
getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(530, 480, 104, -
1));

c3.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

c3.setModel(new
javax.swing.DefaultComboBoxModel<>(new String[] { "Select
Stream", "Commerce", "Science", "Arts" }));

c3.addActionListener(new java.awt.event.ActionListener()
{

public void
actionPerformed(java.awt.event.ActionEvent evt) {

c3ActionPerformed(evt);

});

getContentPane().add(c3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(470, 380, 160, -
1));

c4.setFont(new java.awt.Font("Tahoma", 1, 14)); //


NOI18N

c4.setModel(new
javax.swing.DefaultComboBoxModel<>(new String[] { "Select
Class" }));

c4.addActionListener(new java.awt.event.ActionListener()
{
public void
actionPerformed(java.awt.event.ActionEvent evt) {

c4ActionPerformed(evt);

});

getContentPane().add(c4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(470, 430, 160, -
1));

jLabel6.setFont(new java.awt.Font("Lucida Handwriting",


0, 36)); // NOI18N

jLabel6.setForeground(new java.awt.Color(0, 102, 102));

jLabel6.setText("Add a New Book");

getContentPane().add(jLabel6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(330, 170, -1, -
1));

jButton3.setBackground(new java.awt.Color(0, 102, 102));

jButton3.setFont(new java.awt.Font("Tahoma", 1, 12)); //


NOI18N

jButton3.setForeground(new java.awt.Color(255, 255,


255));

jButton3.setText("Home");

jButton3.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

getContentPane().add(jButton3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(330, 560, -1, -
1));

jButton4.setBackground(new java.awt.Color(0, 102, 102));

jButton4.setFont(new java.awt.Font("Tahoma", 1, 12)); //


NOI18N

jButton4.setForeground(new java.awt.Color(255, 255,


255));

jButton4.setText("Issue Book");

jButton4.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton4ActionPerformed(evt);

});

getContentPane().add(jButton4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(440, 560, -1, -
1));
jButton5.setBackground(new java.awt.Color(0, 102, 102));

jButton5.setFont(new java.awt.Font("Tahoma", 1, 11)); //


NOI18N

jButton5.setForeground(new java.awt.Color(255, 255,


255));

jButton5.setText("Return Book");

jButton5.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton5ActionPerformed(evt);

});

getContentPane().add(jButton5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(580, 560, -1, -
1));

jButton6.setBackground(new java.awt.Color(0, 102, 102));

jButton6.setFont(new java.awt.Font("Tahoma", 1, 11)); //


NOI18N

jButton6.setForeground(new java.awt.Color(255, 255,


255));

jButton6.setText("Issued Book Details");


jButton6.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton6ActionPerformed(evt);

});

getContentPane().add(jButton6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(710, 560, -1, -
1));

jButton7.setBackground(new java.awt.Color(0, 102, 102));

jButton7.setFont(new java.awt.Font("Tahoma", 1, 12)); //


NOI18N

jButton7.setForeground(new java.awt.Color(255, 255,


255));

jButton7.setText("Book Details");

jButton7.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton7ActionPerformed(evt);

});
getContentPane().add(jButton7, new
org.netbeans.lib.awtextra.AbsoluteConstraints(880, 560, -1, -
1));

getContentPane().add(jLabel7, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

jLabel8.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/new
back.jpg"))); // NOI18N

getContentPane().add(jLabel8, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

pack();

}// </editor-fold>

private void c4ActionPerformed(java.awt.event.ActionEvent


evt) {

private void c3ActionPerformed(java.awt.event.ActionEvent


evt) {

if(c3.getSelectedItem()=="Science")

c4.removeAllItems();
c4.addItem("Select
Class");c4.addItem("FYBScCS");c4.addItem("SYBScCS");c4.addIt
em("TYBScCS");

if(c3.getSelectedItem()=="Arts")

c4.removeAllItems();

c4.addItem("Select
Class");c4.addItem("FYBA");c4.addItem("SYBA");c4.addItem("TY
BA");

if(c3.getSelectedItem()=="Commerce")

c4.removeAllItems();

c4.addItem("Select
Class");c4.addItem("FYBCom");c4.addItem("SYBCom");c4.addIte
m("TYBCom");

private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

MainLayer mn=new MainLayer();

mn.setVisible(true);

this.setVisible(false);
}

private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

MainLayer mn=new MainLayer();

mn.setVisible(true);

this.setVisible(false);

private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

if(txt2.getText().equals(""))

JOptionPane.showMessageDialog(this,"Please enter
Book id");

else if(txt3.getText().equals(""))

JOptionPane.showMessageDialog(this,"Please enter
Book name");

else if(txt4.getText().equals(""))

JOptionPane.showMessageDialog(this,"Please enter
author name");

else if(c3.getSelectedItem().equals("Select Stream"))

JOptionPane.showMessageDialog(this,"Please select
stream");

else if(c4.getSelectedItem().equals("Select Class"))


JOptionPane.showMessageDialog(this,"Please select
class");

else

try

connect();

query="insert into books


values('"+txt2.getText()+"','"+txt3.getText()+"','"+txt4.getText()+"'
,'"+c3.getSelectedItem()+"','"+c4.getSelectedItem()+"','YES');";

stmt.executeUpdate(query);

disconnect();

JOptionPane.showMessageDialog(this,"New book added to


Library");

txt2.setText("");

txt3.setText("");

txt4.setText("");

c3.setSelectedIndex(0);

c4.removeAllItems();

c4.addItem("Select Class");

catch(SQLException e)
{

if(e.getErrorCode()==1062)

JOptionPane.showMessageDialog(this,"BookId is a
primary key\nduplicate entry is not allowed\nit should be
unique");

else

JOptionPane.showMessageDialog(this,"connection
error");

private void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

IssueBook ib=new IssueBook();

ib.setVisible(true);

this.setVisible(false);

private void
jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

ReturnBook rb=new ReturnBook();

rb.setVisible(true);
this.setVisible(false);

private void
jButton6ActionPerformed(java.awt.event.ActionEvent evt) {

IssuedBooks ibs=new IssuedBooks();

ibs.setVisible(true);

this.setVisible(false);

private void
jButton7ActionPerformed(java.awt.event.ActionEvent evt) {

BookDetails bd=new BookDetails();

bd.setVisible(true);

this.setVisible(false);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */


//<editor-fold defaultstate="collapsed" desc=" Look and
feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available,


stay with the default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfe
el/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(AddNewBook.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(AddNewBook.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {


java.util.logging.Logger.getLogger(AddNewBook.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException
ex) {

java.util.logging.Logger.getLogger(AddNewBook.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 AddNewBook().setVisible(true);

});

public void connect()

try

Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(

"jdbc:mysql://localhost:3306/library?useSSL=false&autoRecon
nect=true","root","root");

stmt=con.createStatement();

catch(Exception e)

JOptionPane.showMessageDialog(this,"connection
error");

public void disconnect()

try

con.close();

catch(Exception e)

{}

}
// Variables declaration - do not modify

private javax.swing.JComboBox<String> c3;

private javax.swing.JComboBox<String> c4;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;

private javax.swing.JButton jButton6;

private javax.swing.JButton jButton7;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JTextField txt2;

private javax.swing.JTextField txt3;

private javax.swing.JTextField txt4;

// End of variables declaration }


Issue Book Details:

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

public class IssuedBooks extends javax.swing.JFrame {

Connection con;

Statement stmt;

ResultSet rs;

String query;

/**

* Creates new form IssuedBooks

*/
public IssuedBooks() {

initComponents();

/**

* This method is called from within the constructor to


initialize the form.

* WARNING: Do NOT modify this code. The content of this


method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated


Code">

private void initComponents() {

jLabel1 = new javax.swing.JLabel();

jScrollPane1 = new javax.swing.JScrollPane();

table = new javax.swing.JTable();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();


jButton5 = new javax.swing.JButton();

jButton6 = new javax.swing.JButton();

c1 = new javax.swing.JComboBox<>();

c2 = new javax.swing.JComboBox<>();

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

jLabel4 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_
ON_CLOSE);

setUndecorated(true);

getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());

jLabel1.setFont(new java.awt.Font("Lucida Handwriting",


0, 36)); // NOI18N

jLabel1.setForeground(new java.awt.Color(0, 102, 102));

jLabel1.setText("Issued Book Details");

getContentPane().add(jLabel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(490, 170, -1, -
1));
table.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

"Student Id", "Student Name", "Book Id", "Book


Name", "Student Address", "Issue Date"

));

jScrollPane1.setViewportView(table);

if (table.getColumnModel().getColumnCount() > 0) {

table.getColumnModel().getColumn(0).setPreferredWidth(40);

table.getColumnModel().getColumn(1).setPreferredWidth(150);

table.getColumnModel().getColumn(2).setPreferredWidth(30);

table.getColumnModel().getColumn(3).setPreferredWidth(150);

table.getColumnModel().getColumn(4).setPreferredWidth(200);

table.getColumnModel().getColumn(5).setPreferredWidth(60);

}
getContentPane().add(jScrollPane1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(290, 300, 828,
246));

jButton1.setBackground(new java.awt.Color(0, 102, 102));

jButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton1.setForeground(new java.awt.Color(255, 255,


255));

jButton1.setText("Home");

jButton1.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(290, 580, -1, -
1));

jButton2.setBackground(new java.awt.Color(0, 102, 102));

jButton2.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton2.setForeground(new java.awt.Color(255, 255,


255));
jButton2.setText("Book Details");

jButton2.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(400, 580, -1, -
1));

jButton3.setBackground(new java.awt.Color(0, 102, 102));

jButton3.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton3.setForeground(new java.awt.Color(255, 255,


255));

jButton3.setText("AddNewBook");

jButton3.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});
getContentPane().add(jButton3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(550, 580, -1, -
1));

jButton4.setBackground(new java.awt.Color(0, 102, 102));

jButton4.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton4.setForeground(new java.awt.Color(255, 255,


255));

jButton4.setText("Issue Book");

jButton4.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton4ActionPerformed(evt);

});

getContentPane().add(jButton4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(700, 580, -1, -
1));

jButton5.setBackground(new java.awt.Color(0, 102, 102));

jButton5.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton5.setForeground(new java.awt.Color(255, 255,


255));
jButton5.setText("Return Book");

jButton5.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton5ActionPerformed(evt);

});

getContentPane().add(jButton5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(840, 580, -1, -
1));

jButton6.setBackground(new java.awt.Color(0, 102, 102));

jButton6.setFont(new java.awt.Font("Tahoma", 0, 12)); //


NOI18N

jButton6.setForeground(new java.awt.Color(255, 255,


255));

jButton6.setText("Student Registration");

jButton6.addActionListener(new
java.awt.event.ActionListener() {

public void
actionPerformed(java.awt.event.ActionEvent evt) {

jButton6ActionPerformed(evt);

});
getContentPane().add(jButton6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(980, 580, -1, -
1));

c1.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

c1.setModel(new
javax.swing.DefaultComboBoxModel<>(new String[] { "Select
Stream", "Commerce", "Science", "Arts" }));

c1.addActionListener(new java.awt.event.ActionListener()
{

public void
actionPerformed(java.awt.event.ActionEvent evt) {

c1ActionPerformed(evt);

});

getContentPane().add(c1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(460, 220, -1, -
1));

c2.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

c2.setModel(new
javax.swing.DefaultComboBoxModel<>(new String[] { "Select
Class" }));

c2.addActionListener(new java.awt.event.ActionListener()
{
public void
actionPerformed(java.awt.event.ActionEvent evt) {

c2ActionPerformed(evt);

});

getContentPane().add(c2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(810, 220, -1, -
1));

jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel2.setText("Stream");

getContentPane().add(jLabel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(390, 220, -1, -
1));

jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); //


NOI18N

jLabel3.setText("Class");

getContentPane().add(jLabel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(750, 220, -1, -
1));

getContentPane().add(jLabel4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
jLabel5.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/new
back.jpg"))); // NOI18N

getContentPane().add(jLabel5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

pack();

}// </editor-fold>

private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

MainLayer mn=new MainLayer();

mn.setVisible(true);

this.setVisible(false);

private void c1ActionPerformed(java.awt.event.ActionEvent


evt) {

if(c1.getSelectedItem()=="Science")

c2.removeAllItems();

c2.addItem("Select
Class");c2.addItem("FYBScCS");c2.addItem("SYBScCS");c2.addIt
em("TYBScCS");

}
if(c1.getSelectedItem()=="Arts")

c2.removeAllItems();

c2.addItem("Select
Class");c2.addItem("FYBA");c2.addItem("SYBA");c2.addItem("TY
BA");

if(c1.getSelectedItem()=="Commerce")

c2.removeAllItems();

c2.addItem("Select
Class");c2.addItem("FYBCom");c2.addItem("SYBCom");c2.addIte
m("TYBCom");

private void c2ActionPerformed(java.awt.event.ActionEvent


evt) {

try

connect();

query="select * from issue where


SStream='"+c1.getSelectedItem()+"' and
SClass='"+c2.getSelectedItem()+"';";

rs=stmt.executeQuery(query);
DefaultTableModel
model=(DefaultTableModel)table.getModel();

model.setRowCount(0);

while(rs.next())

Object[] row =
{rs.getString("StudentId"),rs.getString("StudentName"),rs.getStri
ng("BookId"),rs.getString("BookName"),rs.getString("Address"),rs
.getString("IssueDate")};

model.addRow(row);

catch(Exception e)

private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

BookDetails bd=new BookDetails();

bd.setVisible(true);

this.setVisible(false);

}
private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

AddNewBook anb=new AddNewBook();

anb.setVisible(true);

this.setVisible(false);

private void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

IssueBook ib=new IssueBook();

ib.setVisible(true);

this.setVisible(false);

private void
jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

ReturnBook rb=new ReturnBook();

rb.setVisible(true);

this.setVisible(false);

private void
jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
RegisterStudent r=new RegisterStudent();

r.setVisible(true);

this.setVisible(false);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and


feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available,


stay with the default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfe
el/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(IssuedBooks.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(IssuedBooks.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(IssuedBooks.class.getName()).
log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException
ex) {

java.util.logging.Logger.getLogger(IssuedBooks.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 IssuedBooks().setVisible(true);

});

public void connect()

try

Class.forName("com.mysql.jdbc.Driver");

con=DriverManager.getConnection(

"jdbc:mysql://localhost:3306/library?useSSL=false&autoRecon
nect=true","root","root");

stmt=con.createStatement();

catch(Exception e)

JOptionPane.showMessageDialog(this,"connection
error");

}
public void disconnect()

try

con.close();

catch(Exception e)

{}

// Variables declaration - do not modify

private javax.swing.JComboBox<String> c1;

private javax.swing.JComboBox<String> c2;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;

private javax.swing.JButton jButton6;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;


private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JTable table;

// End of variables declaration

}
Screen :
Login:

Main Layer:
Student Register:

Add New Book:


Book Details:

Issue Book:
Issue Book Details:

Return Book:
Conclusion:

The Library Management System is much


more user-friendly, faster in operation and
easy to manage than the manual one.
Through the use of it, the librarian can
manage the whole data of the library in a
single database in different tables with a
much more security than the traditional way

You might also like