library project Java netbeans
library project Java netbeans
We take this occasion to thank God, almighty for blessing us with his grace and
taking our endeavour to a successful culmination and our school Bhadrachalam
Public School & Junior College.
Last but not the least, we would like to thank our friends and family for the
support and encouragement they have given us during the course of our work.
BPSJC Page 1
Introduction
The project titled Library Management System is for monitoring and
controlling the transactions in a library .The project “Library Management
System” is developed in Netbeans IDE, which mainly focuses on basic
operations In a library like adding new student, new books, and updating new
information, Searching books and students and facility to borrow and return
books.
PROPOSED SYSTEM:
Proposed system is an automated Library Management System. Through our
software user can add members, add books, search members, search books,
update information, edit information, borrow and return books in quick time.
Our proposed system has the following advantages.
User friendly interface
Less error
Search facility
All the manual difficulties in managing the Library have been rectified by
implementing computerization.
BPSJC Page 2
Insertion – Data such as names, phone numbers, identification numbers,
can be inserted and stored in case of book and student.
Search- One may search the they wished about the book or the student.
Transactions – One can take the book from the library from the
availability basis.
Hard Disk: 20 GB
Software Requirements
BPSJC Page 3
FEASIBILITY
Economical Feasibility
Technhical Feasibility
The technical requirement for the system is economic and it does not use any
other additional Hardware and Software.
Behavioural Feasibility
The system working is quite easy to use and learn due to its simple but
attractive interface . User requires no special training for operating the system.
BPSJC Page 4
Tables
Book_details
Student_details
Transactions
BPSJC Page 5
Subscriptions
BPSJC Page 6
Name
ER-Diagram
Phone no
DOB Roll no
Student Name
Accno Address
Book Name Student
Date of return
Make Name
Accno Author
Rack no
Availability
Price
BPSJC Page 7
Login Form
This login form is made for security purpose. So only Authenticated user only can access
in to the project.
new MainMenu().setVisible(true);
this.dispose();
} else {
userTF.setText("");
pwdPD.setText("");
userTF.requestFocus();
}}
BPSJC Page 8
Main Menu
This is the
homepage, the main menu from where one can choose what to do next.It comes instantly
after you log in successfully.
Source Code:
private void addBookMIActionPerformed(java.awt.event.ActionEvent evt) {
new addbook().setVisible(true);
this.dispose();
new modifybookdetails().setVisible(true);
this.dispose();
BPSJC Page 9
private void addstuMIActionPerformed(java.awt.event.ActionEvent evt) {
new Addstudent().setVisible(true);
this.dispose();
new modifystudentdetails().setVisible(true);
this.dispose();
new search_book_details().setVisible(true);
this.dispose();
new search_student_details().setVisible(true);
this.dispose();
new lend().setVisible(true);
this.dispose();
BPSJC Page 10
private void returnMIActionPerformed(java.awt.event.ActionEvent evt) {
new returnbook().setVisible(true);
this.dispose();
new subscriptions().setVisible(true);
this.dispose();
new about().setVisible(true);
this.dispose();
System.exit(0);
BPSJC Page 11
About Form
Source Code
private void returnBTNActionPerformed(java.awt.event.ActionEvent evt) {
new MainMenu().setVisible(true);
this.dispose();
BPSJC Page 12
ConnectDB Method:
package library;
import java.sql.*;
import javax.swing.JOptionPane;
try {
Class.forName("java.sql.Driver");
return con;
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
return null;
BPSJC Page 13
}
Add Book
A filled up form to add a new Book to Library. On Clicking Add button it inserts the record
into Mysql table book_details.
Source Code
package library;
import java.sql.*;
import javax.swing.JOptionPane;
BPSJC Page 14
import net.proteanit.sql.DbUtils;
Connection con;
Statement stmt;
ResultSet rs;
PreparedStatement pst,pst1;
public addbook() {
initComponents();
con = ConnectDB.connectMySQL();
int no=0;
try{
pst=con.prepareStatement(accnosql);
BPSJC Page 15
rs=pst.executeQuery();
if(rs.next()) {
no=rs.getInt("book");
pst1=con.prepareStatement(sql);
pst1.setString(1, name);
pst1.setInt(2, no);
pst1.setString(3,author);
pst1.setInt(4,price);
pst1.setInt(5,rack);
pst1.setInt(6,copy);
pst1.setString(7,ava);
pst1.executeUpdate();
stmt = con.createStatement();
rs = stmt.executeQuery(sql1);
bookTB.setModel(DbUtils.resultSetToTableModel(rs));
}catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
nameTF.setText("");
authorTF.setText("");
BPSJC Page 16
priceTF.setText("");
rackTF.setText("");
copiesTF.setText("");
avaliableTF.setText("");
nameTF.requestFocus();
new MainMenu().setVisible(true);
this.dispose();
Output
BPSJC Page 17
Modify Book Details
Source Code
package library;
BPSJC Page 18
import java.sql.*;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
Connection con;
Statement stmt;
ResultSet rs;
public modifybookdetails() {
initComponents();
con = ConnectDB.connectMySQL();
nameTF.setEditable(true);
authorTF.setEditable(true);
priceTF.setEditable(true);
rackTF.setEditable(true);
copiesTF.setEditable(true);
availableTF.setEditable(true);
try {
stmt = con.createStatement();
BPSJC Page 19
rs = stmt.executeQuery(sql);
rs.next();
accTF.setText(rs.getString("accNo"));
nameTF.setText(rs.getString("Book_Name"));
authorTF.setText(rs.getString("Author"));
priceTF.setText(rs.getInt("Price") + "");
rackTF.setText(rs.getInt("Rack_no") + "");
copiesTF.setText(rs.getInt("Copies") + "");
availableTF.setText(rs.getString("Availability"));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
bookTB.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
BPSJC Page 20
int acc = Integer.parseInt(accTF.getText());
try {
stmt = con.createStatement();
stmt.executeUpdate(sql);
updateTable();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
try {
stmt = con.createStatement();
stmt.executeUpdate(sql);
updateTable();
} catch (Exception e) {
BPSJC Page 21
JOptionPane.showMessageDialog(null, e.getMessage());
accTF.setText("");
nameTF.setText("");
authorTF.setText("");
priceTF.setText("");
rackTF.setText("");
copiesTF.setText("");
availableTF.setText("");
accTF.requestFocus();
new MainMenu().setVisible(true);
this.dispose();
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
bookTB.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
BPSJC Page 22
}
Output
Add Student
BPSJC Page 23
A form to add a student. Clicking on add button inserts the record into Mysql table
Student_details.
Source Code
package library;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
Connection con;
Statement stmt;
ResultSet rs;
BPSJC Page 24
PreparedStatement pst, pst1;
public Addstudent() {
initComponents();
con = ConnectDB.connectMySQL();
int no = 0;
try {
pst = con.prepareStatement(rollnosql);
rs = pst.executeQuery();
if (rs.next()) {
no = rs.getInt("rollno");
pst1 = con.prepareStatement(sql);
pst1.setInt(1, no);
pst1.setString(2, name);
pst1.setString(3, addr);
pst1.setLong(4, pno);
pst1.setString(5, date);
BPSJC Page 25
pst1.executeUpdate();
stmt = con.createStatement();
rs = stmt.executeQuery(sql1);
memberTB.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
nameTF.setText("");
addrTA.setText("");
pnoTF.setText("");
dateTF.setText("");
nameTF.requestFocus();
new MainMenu().setVisible(true);
this.dispose();
Calendar c = Calendar.getInstance();
c.setTime(jDateChooser1.getDate());
BPSJC Page 26
dateTF.setText(sdf.format(c.getTime()));
Output
BPSJC Page 27
Modify Student Details
Source Code
package library;
import java.sql.*;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
BPSJC Page 28
Connection con;
Statement stmt;
ResultSet rs;
public modifystudentdetails() {
initComponents();
con = ConnectDB.connectMySQL();
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
studentTB.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
nameTF.setEditable(true);
pnoTF.setEditable(true);
dateTF.setEditable(true);
addrTA.setEditable(true);
BPSJC Page 29
String sql = "select * from student_details where Rollno=" + no;
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
if (rs.next()) {
int id = rs.getInt(1);
noTF.setText(Integer.toString(id));
nameTF.setText(name);
addrTA.setText(addr);
pnoTF.setText(Long.toString(pno));
dateTF.setText(birth);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
int no = Integer.parseInt(noTF.getText());
BPSJC Page 30
String date = dateTF.getText();
try {
stmt = con.createStatement();
stmt.executeUpdate(sql);
updateTable();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
int id = Integer.parseInt(noTF.getText());
try {
stmt = con.createStatement();
stmt.executeUpdate(sql);
updateTable();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
noTF.setText("");
BPSJC Page 31
nameTF.setText("");
addrTA.setText("");
pnoTF.setText("");
dateTF.setText("");
noTF.requestFocus();
new MainMenu().setVisible(true);
this.dispose();
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
studentTB.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
Output
BPSJC Page 32
Search Book Details
We can search the book details available in the library in this form-A successful search.
Source Code
package library;
import java.sql.*;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
BPSJC Page 33
public class search_book_details extends javax.swing.JFrame {
Connection con;
Statement stmt;
ResultSet rs;
public search_book_details() {
initComponents();
con = ConnectDB.connectMySQL();
String criteria;
if (accRB.isSelected()) {
criteria = "AccNo";
} else {
criteria = "Author";
String sql = "select * from book_details where " + criteria + " like '%" + valueTF.getText()
+ "%';";
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
bookTB.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
BPSJC Page 34
}
new MainMenu().setVisible(true);
this.dispose();
Output
BPSJC Page 35
Search Student Details
We can search the book details available in the library in this form-A successful search.
Source Code
package library;
BPSJC Page 36
import java.sql.*;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
Connection con;
Statement stmt;
ResultSet rs;
public search_student_details() {
initComponents();
con = ConnectDB.connectMySQL();
String criteria;
if (rollRB.isSelected()) {
criteria = "Rollno";
} else {
criteria = "Student_Name";
String sql = "select * from student_details where " + criteria + " like '%" +
valueTF.getText() + "%';";
try {
BPSJC Page 37
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
memberTB.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
new MainMenu().setVisible(true);
this.dispose();
Output
BPSJC Page 38
Subscriptions
BPSJC Page 39
Source Code
package library;
import java.sql.*;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
Connection con;
Statement stmt;
ResultSet rs;
public subscriptions() {
initComponents();
con = ConnectDB.connectMySQL();
int id = Integer.parseInt(idTF.getText());
BPSJC Page 40
String sql = "insert into subscriptions values('" + name + "'," + id + ",'" + date + "'," +
price + "," + copies + ");";
try {
stmt = con.createStatement();
stmt.executeUpdate(sql);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql1);
subTable.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
nameTF.setText((String) subscribeCB.getSelectedItem());
nameTF.setText("");
idTF.setText("");
dateTF.setText("");
BPSJC Page 41
priceTF.setText("");
copyTF.setText("");
nameTF.requestFocus();
new MainMenu().setVisible(true);
this.dispose();
Output
BPSJC Page 42
Avaliability Form
Source Code
package library;
import java.sql.*;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
Connection con;
Statement stmt;
ResultSet rs;
public avaliability() {
initComponents();
con = ConnectDB.connectMySQL();
BPSJC Page 43
private void avaliableBTNActionPerformed(java.awt.event.ActionEvent evt) {
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
bookTable.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
if (copy != 0) {
this.dispose();
} else {
BPSJC Page 44
}
Transactions
Lend a book
A form to lend the book to the students which are available in the library.
Source Code
package library;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
BPSJC Page 45
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
Connection con;
Statement stmt;
ResultSet rs;
public lend() {
initComponents();
con = ConnectDB.connectMySQL();
this();
accTF.setText(Integer.toString(accno));
nameTF.setText(bookname);
new avaliability().setVisible(true);
this.dispose();
BPSJC Page 46
String sname = nameCB.getSelectedItem().toString();
String sql = "insert into transactions values(" + acc + ",'" + name + "','" + sname + "','" +
issue + "','" + retur + "');";
try {
stmt = con.createStatement();
stmt.executeUpdate(sql);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql1);
transTable.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
try {
stmt = con.createStatement();
stmt.executeUpdate(sql2);
} catch (Exception e) {
BPSJC Page 47
JOptionPane.showMessageDialog(null, e.getMessage());
Calendar c = Calendar.getInstance();
c.setTime(jDateChooser1.getDate());
issueTF.setText(sdf.format(c.getTime()));
c.add(Calendar.DATE, 30);
returnTF.setText(sdf.format(c.getTime()));
accTF.setText("");
nameTF.setText("");
issueTF.setText("");
returnTF.setText("");
accTF.requestFocus();
new MainMenu().setVisible(true);
this.dispose();
Output
BPSJC Page 48
BPSJC Page 49
Return the book
Source Code
package library;
import java.sql.*;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
Connection con;
Statement stmt;
BPSJC Page 50
ResultSet rs;
public returnbook() {
initComponents();
con = ConnectDB.connectMySQL();
try {
stmt = con.createStatement();
stmt.executeUpdate(sql);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql1);
transTable.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
BPSJC Page 51
try {
stmt = con.createStatement();
stmt.executeUpdate(sql2);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
accTF.setText("");
nameTF.setText("");
accTF.requestFocus();
new MainMenu().setVisible(true);
this.dispose();
Output
BPSJC Page 52
Conclusion:
The Library Management System is developed using NetBeans fully meets the
objectives of the system which it has been developed. The system has reached a
steady state where all bugs have been eliminated. The system is operated at a high
level of efficiency and all the students associated with the system understand its
advantage. The system solves the problem. It was intended to solve as requirement
specification.
Bibliography
1. www.W3schools.in
2. www.Cbse.nic.in
BPSJC Page 53