0% found this document useful (0 votes)
186 views

Java Project Report

class 12 project java

Uploaded by

Deepanshu Arya
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
186 views

Java Project Report

class 12 project java

Uploaded by

Deepanshu Arya
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 32

A Project Report

on

Public Library Management System

For

SUBMITTED BY
…………..
[Roll No…….]

Under the Guidance of:


…………….
PGT (Comp.Sc)
CERTIFICATE

This is to certify that the Project / Dissertation entitled

Public Library Management System is a bonafide work

done by Master ………. of class XII Session 2010-11 in

partial fulfillment of CBSE’s AISSCE Examination 2011

and has been carried out under my direct supervision and

guidance. This report or a similar report on the topic has

not been submitted for any other examination and does

not form a part of any other course undergone by the

candidate.

………………………… ……………………………..
Signature of Student Signature of Teacher/Guide

Name: ………. Name: ………………..


Roll No.: …………………… Designation: PGT (Comp.Sc.)

……….…………………
Signature of Principal
Name: ………………….
Place:…………….
Date:……………..
ACKNOWLEDGEMENT

I
undertook this Project work, as the part of my XII-Informatics
Practices course. I had tried to apply my best of knowledge and
experience, gained during the study and class work experience.
However, developing software system is generally a quite complex and
time-consuming process. It requires a systematic study, insight vision and
professional approach during the design and development. Moreover, the
developer always feels the need, the help and good wishes of the people
near you, who have considerable experience and idea.

I would like to extend my sincere thanks and gratitude to my teacher


……………. I am very much thankful to our Principal Mr………………..
for giving valuable time and moral support to develop this software.

I would like to take the opportunity to extend my sincere thanks and


gratitude to my father Sri …….., and my mother Mrs. …………. for being a
source of inspiration and providing time and freedom to develop this
software project.

I also feel indebted to my friends Mr. ……….. and Mr……….. for the
valuable suggestions during the project work.

…………….
Class XII
Introduction
This software project is developed to automate the functionalities of a

Public Library.The purpose of the software project is to develop the

Management Information System (MIS) to automate the record keeping of

Publishers, Books, Members and Book issue and receive transactions with

a view to enhance the decision making of the functionaries.

A MIS mainly consists of a computerized database, a collection of inter-

related tables for a particular subject or purpose, capable to produce

different reports relevant to the user. An application program is tied with

the database for easy access and interface to the database. Using

Application program or front-end, we can store, retrieve and manage all

information in proper way.

This software, being simple in design and working, does not require much

of training to users, and can be used as a powerful tool for automating a

Public Library System.

During coding and design of the software Project, Java NetBeans IDE, a

powerful front-end tool is used for getting Graphical User Interface (GUI)

based integrated platform and coding simplicity. As a back-end a

powerful, open source RDBMS, My SQL is used as per requirement of the

CBSE curriculum of Informatics Practices Course.


2. Objective & Scope of the Project

T he objective of the software project is to develop a computerized MIS to automate the


functions of a Public Library This software project is also aimed to enhance the current
record keeping system, which will help managers to retrieve the up-to-date information at
right time in right shape.
The proposed software system is expected to do the following functionality-
 To provide a user friendly, Graphical User Interface (GUI) based integrated and
centralized environment for MIS activities.
 The proposed system should maintain all the records and transactions, and should
generate the required reports and information when required.
 To provide graphical and user-friendly interface to interact with a centralized database
based on client-server architecture.
 To identify the critical operation procedure and possibilities of simplification using
modern IT tools and practices.

In its current scope, the software enables user to retrieve and update the information from
centralized database designed with MySQL . This software does not require much training time
of the users due to limited functionality and simplicity.

During the development of Public Library Information System project, Java NetBeans IDE, a
powerful, open source event-driven form-based development environment is used for modular
design and future expandability of the system.

Despite of the best effort of the developer, the following limitations and functional boundaries
are visible, which limits the scope of this application software.

1. This software can store records and produce reports in pre-designed format in soft copy.
There is no facility yet to produce customized reports. Only specified reports are
covered.

2. There is no provision to calculate fine or penalty etc. for defaulter members; however it
can be developed easily with the help of adding modules.

3. Some application area like accounting of books and fines etc. are not implemented in the
project. It facilitates librarian to record and update only transaction record.

So far as future scope of the project is concerned, firstly it is open to any modular expansion i.e.
other modules or functions can be designed and embedded to handle the user need in future. Any
part of the software and reports can be modified independently without much effort.
System Implementation

5.1 The Hardware used:

While developing the system, the used hardware are:


PC with Pentium IV processor or sometimes, PC with Celeron (1.7 GHz) processor
having 256 MB RAM, SVGA and other required devices.

5.2 The Softwares used:


 Microsoft Windows® XP as Operating System.

 Java NetBeans 6.9 as Front-end Development environment.

 MySQL as Back-end Sever with Database for Testing.

 MS-Word 2000 for documentation.


6. System Design & Development

6.1 Database Design:


An important aspect of system design is the design of data storage structure. To begin with a
logical model of data structure is developed first. A database is a container object which contains
tables, queries, reports and data validation policies enforcement rules or contraints etc. A logical
data often represented as a records are kept in different tables after reducing anomalies and
redundancies. The goodness of data base design lies in the table structure and its relationship.
This software project maintains a database named Library which contains the following tables.

Table Design:
The database of Library System contains 5 tables. The tables are normalized to minimize the
redundancies of data and enforcing the validation rules of the organization. Most of the tables
are designed to store master records. The tables and their structure are given below.

Table: Publisher
Column Name Type Size
Pub_ID (Primary Key) Integer 4
Pub_Name Varchar 30
Pub_Address Varchar 40
Pub_Phone1 Varchar 12
Pub_Phone2 Varchar 12
Status Char 1

Table: Lib
Column Name Type Size
ACC_No (Primary Key) Integer 4
Acq_No Integer 4
BTitle Varchar 30
Author1 Varchar 30
Author2 Varchar 30
Pub_ID (Foreign Key-Reference Publisher) Integer 4
Price Float(8,2) 8
PDate Date
Pages Integer 4
Edition Integer 4
Status Char 1

Table: Member
Column Name Type Size
Memb_No (Primary Key) Integer 4
Memb_Name Varchar 30
Memb_Add Varchar 40
Memb_Phone Varchar 12
MDate Date
MEDate Date
MFee Float(8,2) 4
Mem_Status Char 1
Mem_Issue Char 1
Table: MIssue
Column Name Type Size
ACC_No Integer 4
Acq_No Integer 4
Memb_No Integer 4
IDate Date 10
RDate Date 10

Table: TIssue
Column Name Type Size
ACC_No Integer 4
Memb_No Integer 4
IDate Date 10
RDate Date 10

Forms Design & Event Coding:


The software project for Public Library Management contains various forms along with
programming codes. Forms (JFrames) and their event coding are given below.

Frame: MainUI.java

Coding for MainUI.java


/**MainUI.java**/
public class MainUI extends javax.swing.JFrame {
/** Creates new form MainUI */
public MainUI() {
initComponents();
}
private void mnuPubActionPerformed(java.awt.event.ActionEvent evt) {
//this.setVisible(false);
new pubUI().setVisible(true);
new pubUI().getAlignmentX();
}
private void mnuQuitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void mnuPModActionPerformed(java.awt.event.ActionEvent evt) {
new PubEditUI().setVisible(true);
}
private void mnuPDelActionPerformed(java.awt.event.ActionEvent evt) {
new PubDelUI().setVisible(true);
}
private void mnuPNavActionPerformed(java.awt.event.ActionEvent evt) {
new PubNavUI().setVisible(true);
}
private void mnuLibActionPerformed(java.awt.event.ActionEvent evt) {
new LibUI().setVisible(true);
}
private void mnuMembActionPerformed(java.awt.event.ActionEvent evt) {
new MembUI().setVisible(true);
}
private void mnuMModActionPerformed(java.awt.event.ActionEvent evt) {
new MembEditUI().setVisible(true);
}
private void mnuMDelActionPerformed(java.awt.event.ActionEvent evt) {
new MembDelUI().setVisible(true);
}
private void mnuMNavActionPerformed(java.awt.event.ActionEvent evt) {
new MembNavUI().setVisible(true);
}
private void mnuIssueActionPerformed(java.awt.event.ActionEvent evt) {
new IssueUI().setVisible(true);
}
private void mnuReturnActionPerformed(java.awt.event.ActionEvent evt) {
new ReturnUI().setVisible(true);
}
private void mnuABListActionPerformed(java.awt.event.ActionEvent evt) {
new ABListUI().setVisible(true);
}
private void mnuIBListActionPerformed(java.awt.event.ActionEvent evt) {
new IBListUI().setVisible(true);
}
private void mnuMListActionPerformed(java.awt.event.ActionEvent evt) {
new MListUI().setVisible(true);
}
private void mnuLibEditActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new LibEditUI().setVisible(true);
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new LibDelUI().setVisible(true);
}
/** * @param args the command line arguments */
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainUI().setVisible(true);
}
});
}

Frame: PubUI.java

Coding of pubUI.java
import java.sql.*;
import javax.swing.JOptionPane;
private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new MainUI().setVisible(true);
}
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtPno.setEditable(false);
// Deactivate the Save button when form loads
cmdSave.setEnabled(false);
}
private void cmdNewActionPerformed(java.awt.event.ActionEvent evt) {
// Activate the Save button when New button clicked
cmdSave.setEnabled(true);
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
Statement stmt = null;
ResultSet rs = null; // ResultSet for publisher table.
String SQL = "SELECT * FROM publisher";
stmt = con.createStatement(); // Connection string for ResultSet - rs.
rs = stmt.executeQuery(SQL);
int pno = 1;
int PID=0;
while (rs.next()) {
PID = rs.getInt("pub_id");
pno++;
}
PID++;
pno = PID;
txtPno.setText(Integer.toString(pno));
txtPName.setFocusable(true);
con.close();
rs.close();
stmt.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT * FROM publisher";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
int Pno = Integer.parseInt(txtPno.getText());
String PName = txtPName.getText();
String PAdd = txtPAdd.getText();
String Pph1 = txtPh1.getText();
String Pph2 = txtPh2.getText();
char PStatus = 'Y';
int code = JOptionPane.showConfirmDialog(this, "Are you sure to add?", "Confirmation Dialog
Box", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
if (code == JOptionPane.YES_OPTION) {
String strSQL = "INSERT INTO Publisher(pub_id, pub_name, pub_address, pub_phone1,
pub_phone2, status) VALUES ("+(Pno)+", '"+(PName)+"', '"+(PAdd)+"', '"+(Pph1)+"', '"+(Pph2)+"', '"+
(PStatus)+"')";
int rowsEffected = stmt.executeUpdate(strSQL);
JOptionPane.showMessageDialog(this, "Record added successfully into Publisher table");
}
con.close();
stmt.close();
rs.close();
cmdSave.setEnabled(false);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void cmdClearActionPerformed(java.awt.event.ActionEvent evt) {
txtPno.setText("");
txtPName.setText("");
txtPAdd.setText("");
txtPh1.setText("");
txtPh2.setText("");
cmdSave.setEnabled(false);
}
private void cmdEditActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new PubEditUI().setVisible(true);
}
/** * @param args the command line arguments */
/*public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new pubUI().setVisible(true);
new pubUI().setSize(500, 500);
}
});
}*/
}

Frame: PubEditUI.java
Coding for PubEditUI.java
/* * PubEditUI.java **/
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.DefaultListModel;
public class PubEditUI extends javax.swing.JFrame {
/** Creates new form PubEditUI */
public PubEditUI() {
initComponents();
}
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtPno.setEditable(false);
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListModel) jList1.getModel();
// Method to add elements into jList1 control
dModel.clear();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT * FROM Publisher";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String Pno = rs.getString("pub_id");
String PName = rs.getString("pub_name");
// To make the publisher no. as 4 digit because we will extract 4 digit from list value
// in mouse click event.
if (Pno.length() < 4)
{
int x = Pno.length();
int nl = 4 - x;
while (nl > 0){
Pno = Pno + " ";
nl--;
}
}
dModel.addElement(Pno + "- " + PName);
}
jList1.setModel(dModel);
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
private void jList1MouseClicked(java.awt.event.MouseEvent evt) {
// getSelectedValue() method extracts the current cursor location value into a variable
String MPub = (String) jList1.getSelectedValue();
// Extract the first 4 characters as publisher ID into a variable
String PubN =MPub.trim().substring(0, 3);
String query = "SELECT * FROM Publisher WHERE pub_Id = " + PubN + ";";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
// Create SQL statement and execute query.
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
if (rs.next()) {
//PubN = rs.getString("pub_no");
String PubName = rs.getString("pub_name");
String PubAdd = rs.getString("pub_address");
String PubPh1 = rs.getString("pub_phone1");
String PubPh2 = rs.getString("pub_phone2");
String PStatus = rs.getString("status");
// Displaying the contents in respective text boxes.
txtPno.setText(PubN);
txtPName.setText(PubName);
txtPAdd.setText(PubAdd);
txtPh1.setText(PubPh1);
txtPh2.setText(PubPh2);
txtStatus.setText(PStatus);
txtPno.setEditable(false);
// Close the operational object for Student
con.close();
stmt.close();
rs.close();
} else {
JOptionPane.showMessageDialog(null, "Record does not found in Publisher table");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
//new MainUI().setVisible(true);
}
private void cmdUpdateActionPerformed(java.awt.event.ActionEvent evt) {
try {
// Connect to MySQL database
// Don't forget to import the two packages
// import java.sql.*;
// import javax.swing.JOptionPane;
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT * FROM Publisher";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
int pno = Integer.parseInt(txtPno.getText().trim());
String PubName = txtPName.getText();
String PubAdd = txtPAdd.getText();
String PubPh1 = txtPh1.getText();
String PubPh2 = txtPh2.getText();
String PStatus = txtStatus.getText();
String strSQL = "Update publisher set pub_name ='"+(PubName)+"',pub_address = '"+(PubAdd)
+"', pub_phone1 = '"+(PubPh1)+"', pub_phone2 = '"+(PubPh2)+"', status = '"+(PStatus)+"' where pub_id
= " + (pno);
int rowsEffected = stmt.executeUpdate(strSQL);
if (rowsEffected == 0)
JOptionPane.showMessageDialog(this, "Record does not exists");
else
JOptionPane.showMessageDialog(this,"Record modified");
con.close();
stmt.close();
rs.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
/** * @param args the command line arguments */
/*public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PubEditUI().setVisible(true);
}
});
}*/
}
Frame: PubDelUI.java

Coding for PubDelUI.Java


/* PubDelUI.java */
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.DefaultListModel;
public class PubDelUI extends javax.swing.JFrame {
/** Creates new form PubDelUI */
public PubDelUI() {
initComponents();
}
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT * FROM Publisher";
private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
int pno = Integer.parseInt(txtPno.getText().trim());
// Steps to confirm deletion
int opt = JOptionPane.showConfirmDialog(null, "Are you sure to delete this record ?");
if (opt == JOptionPane.YES_OPTION)
{
try {
char stb = 'N'; // Member table
String strSQL = "Update publisher set status ='"+(stb)+"' where pub_id = " + (pno);
int rowsEffected = stmt.executeUpdate(strSQL);
if (rowsEffected == 0)
JOptionPane.showMessageDialog(this, "Record does not exists");
else
{
JOptionPane.showMessageDialog(this,"Record Deleted");
// Text boxes cleared
txtPno.setText("");
txtPName.setText("");
txtPAdd.setText("");
txtPh1.setText("");
txtPh2.setText("");
txtStatus.setText("");
txtPno.setEditable(true);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Unable to delete");
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
//new MainUI().setVisible(true);
}
private void jList1MouseClicked(java.awt.event.MouseEvent evt) {
// getSelectedValue() method extracts the current cursor location value into a variable
String MPub = (String) jList1.getSelectedValue();
// Extract the first 4 characters as roll number into a variable
String PubN =MPub.trim().substring(0, 3);
String query = "SELECT * FROM Publisher WHERE pub_Id = " + PubN + ";";
try {
// Connect to MySQL database
// Don't forget to import the two packages
// import java.sql.*;
// import javax.swing.JOptionPane;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
// Create SQL statement and execute query.
stmt = con.createStatement();
rs = stmt.executeQuery(query);
if (rs.next()) {
//PubN = rs.getString("pub_no");
String PubName = rs.getString("pub_name");
String PubAdd = rs.getString("pub_address");
String PubPh1 = rs.getString("pub_phone1");
String PubPh2 = rs.getString("pub_phone2");
String PStatus = rs.getString("status");
// Displaying the contents in respective text boxes.
txtPno.setText(PubN);
txtPName.setText(PubName);
txtPAdd.setText(PubAdd);
txtPh1.setText(PubPh1);
txtPh2.setText(PubPh2);
txtStatus.setText(PStatus);
txtPno.setEditable(false);
} else {
JOptionPane.showMessageDialog(null, "Record does not found in Student table");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtPno.setEditable(false);
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListModel) jList1.getModel();
// Method to add elements into jList1 control
dModel.clear();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String Pno = rs.getString("pub_id");
String PName = rs.getString("pub_name");
// To make the publisher no. as 4 digit because we will extract 4 digit from list value
// in mouse click event.
if (Pno.length() < 4)
{
int x = Pno.length();
int nl = 4 - x;
while (nl > 0){
Pno = Pno + " ";
nl--;
}
}
dModel.addElement(Pno + "- " + PName);
}
jList1.setModel(dModel);
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
/** * @param args the command line arguments */
/*public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PubDelUI().setVisible(true);
}
});
}*/
}

Frame: PubNavUI.java

Coding of PubNavUI.java
/* PubNavUI.java */
import java.sql.*;
import javax.swing.JOptionPane;
public class PubNavUI extends javax.swing.JFrame {
/** Creates new form PubNavUI */
public PubNavUI() {
initComponents();
}
// Global variables
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT * FROM publisher";
public void disable_textfields() {
txtPno.setEditable(false);
txtPName.setEditable(false);
txtPAdd.setEditable(false);
txtPh1.setEditable(false);
txtPh2.setEditable(false);
txtStatus.setEditable(false);
}
private void cmdFirstActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
if (rs.first()) {
String PubN = rs.getString("pub_id");
String PubName = rs.getString("pub_name");
String PubAdd = rs.getString("pub_address");
String PubPh1 = rs.getString("pub_phone1");
String PubPh2 = rs.getString("pub_phone2");
String PStatus = rs.getString("status");
// Displaying the contents in respective text boxes.
txtPno.setText(PubN);
txtPName.setText(PubName);
txtPAdd.setText(PubAdd);
txtPh1.setText(PubPh1);
txtPh2.setText(PubPh2);
txtStatus.setText(PStatus);
cmdFirst.setEnabled(false);
cmdNext.setEnabled(true);
cmdPrev.setEnabled(false);
cmdLast.setEnabled(true);
} else {
cmdFirst.setEnabled(false);
cmdNext.setEnabled(false);
cmdPrev.setEnabled(false);
cmdLast.setEnabled(false);
JOptionPane.showMessageDialog(this, "Rhere is no record in table", "Student",0);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void cmdNextActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
if (rs.next()) {
String PubN = rs.getString("pub_id");
String PubName = rs.getString("pub_name");
String PubAdd = rs.getString("pub_address");
String PubPh1 = rs.getString("pub_phone1");
String PubPh2 = rs.getString("pub_phone2");
String PStatus = rs.getString("status");
// Displaying the contents in respective text boxes.
txtPno.setText(PubN);
txtPName.setText(PubName);
txtPAdd.setText(PubAdd);
txtPh1.setText(PubPh1);
txtPh2.setText(PubPh2);
txtStatus.setText(PStatus);
cmdFirst.setEnabled(true);
cmdNext.setEnabled(true);
cmdPrev.setEnabled(true);
cmdLast.setEnabled(true);
} else {
cmdNext.setEnabled(false);
JOptionPane.showMessageDialog(this, "You are at last record position", "Student",0);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
}
private void cmdPrevActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
if (rs.previous()) {
String PubN = rs.getString("pub_id");
String PubName = rs.getString("pub_name");
String PubAdd = rs.getString("pub_address");
String PubPh1 = rs.getString("pub_phone1");
String PubPh2 = rs.getString("pub_phone2");
String PStatus = rs.getString("status");
// Displaying the contents in respective text boxes.
txtPno.setText(PubN);
txtPName.setText(PubName);
txtPAdd.setText(PubAdd);
txtPh1.setText(PubPh1);
txtPh2.setText(PubPh2);
txtStatus.setText(PStatus);
cmdFirst.setEnabled(true);
cmdNext.setEnabled(true);
cmdPrev.setEnabled(true);
cmdLast.setEnabled(true);
} else {
cmdPrev.setEnabled(false);
JOptionPane.showMessageDialog(this, "You are at first position", "Student",0);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void cmdLastActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
if (rs.last()) {
String PubN = rs.getString("pub_id");
String PubName = rs.getString("pub_name");
String PubAdd = rs.getString("pub_address");
String PubPh1 = rs.getString("pub_phone1");
String PubPh2 = rs.getString("pub_phone2");
String PStatus = rs.getString("status");
// Displaying the contents in respective text boxes.
txtPno.setText(PubN);
txtPName.setText(PubName);
txtPAdd.setText(PubAdd);
txtPh1.setText(PubPh1);
txtPh2.setText(PubPh2);
txtStatus.setText(PStatus);
cmdFirst.setEnabled(true);
cmdNext.setEnabled(false);
cmdPrev.setEnabled(true);
cmdLast.setEnabled(false);
} else {
JOptionPane.showMessageDialog(this, "You are already at last record", "Student",0);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
disable_textfields();
try {
// Connect to MySQL database
// Don't forget to import the two packages
// import java.sql.*;
// import javax.swing.JOptionPane;
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
if (rs.first())
{
String PubN = rs.getString("pub_id");
String PubName = rs.getString("pub_name");
String PubAdd = rs.getString("pub_address");
String PubPh1 = rs.getString("pub_phone1");
String PubPh2 = rs.getString("pub_phone2");
String PStatus = rs.getString("status");
// Displaying the contents in respective text boxes.
txtPno.setText(PubN);
txtPName.setText(PubName);
txtPAdd.setText(PubAdd);
txtPh1.setText(PubPh1);
txtPh2.setText(PubPh2);
txtStatus.setText(PStatus);
cmdFirst.setEnabled(false);
cmdNext.setEnabled(true);
cmdPrev.setEnabled(false);
cmdLast.setEnabled(true);
}
else
{
cmdFirst.setEnabled(false);
cmdNext.setEnabled(false);
cmdPrev.setEnabled(false);
cmdLast.setEnabled(false);
JOptionPane.showMessageDialog(this, "Rhere is no record in table", "Student",0);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
/** * @param args the command line arguments */
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PubNavUI().setVisible(true);
}
});
}
}

Frame: LibUI.java

Coding for LibUI.java


/* * LibUI.java **/
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.DefaultComboBoxModel;
public class LibUI extends javax.swing.JFrame {
/** Creates new form LibUI */
public LibUI() {
initComponents();
}
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT * FROM Lib";
// for table Publisher
Statement stmt1 = null;
ResultSet rs1 = null;
String SQL1 = "SELECT * FROM publisher";
private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
}
private void cmdEditActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new LibEditUI().setVisible(true);
}
private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
int Acno = Integer.parseInt(txtAcno.getText().trim());
String bTitle = txtBTitle.getText();
String Auth1 = txtAuth1.getText();
String Auth2 = txtAuth2.getText();
// Creating a String object pName
String pName = (String) jComboBox1.getSelectedItem();
// Extract the first 4 characters as publisher number into a variable
String PubNo = String.valueOf(pName.substring(0, 3).trim());
int pno = Integer.parseInt(PubNo);
jLabel10.setText(""+pno);
float Price = Float.parseFloat(txtPrice.getText());
int pages = Integer.parseInt(txtPages.getText());
int edition = Integer.parseInt(txtEdition.getText());
String Pdate = txtPDate.getText();
char BStatus = 'Y';
int code = JOptionPane.showConfirmDialog(this, "Are you sure to add?", "Confirmation Dialog
Box", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
if (code == JOptionPane.YES_OPTION) {
String strSQL = "INSERT INTO Lib(acc_no, btitle, author1, author2, pub_id, price, pdate,
pages, edition, status) VALUES ("+(Acno)+", '"+(bTitle)+"', '"+(Auth1)+"', '"+(Auth2)+"', "+(pno)+", "+
(Price)+", '"+(Pdate)+"', "+(pages)+", "+(edition)+", '"+(BStatus)+"')";
int rowsEffected = stmt.executeUpdate(strSQL);
JOptionPane.showMessageDialog(this, "Record added successfully into Lib table");
}
cmdSave.setEnabled(false);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void cmdNewActionPerformed(java.awt.event.ActionEvent evt) {
// Activate the Save button when New button pressed
cmdSave.setEnabled(true);
DefaultComboBoxModel cModel = (DefaultComboBoxModel) jComboBox1.getModel();
cModel.removeAllElements();
txtStatus.setEditable(false);
// Activate the Save button when New button clicked
cmdSave.setEnabled(true);
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
stmt = con.createStatement(); // Connection string for ResultSet - rs.
rs = stmt.executeQuery(SQL);
int acno=0, ACNO = 0;
while (rs.next()) {
ACNO = rs.getInt("acc_no");
}
ACNO++;
acno = ACNO;
txtAcno.setText(Integer.toString(acno));
stmt1 = con.createStatement(); // To list publishers in JComboBox1 component
rs1 = stmt1.executeQuery(SQL1);
while (rs1.next()) {
String pubno = rs1.getString("pub_id");
String pubName = rs1.getString("pub_name");
// To make the publisher no. as 4 digit because we will extract 4 digit from list value
// in mouse click event
txtStatus.setText("Y"); // Because it is a new book, when it will be issue,
// it's status will be N.
if (pubno.length() < 4)
{
int x = pubno.length();
int nl = 4 - x;
while (nl > 0){
pubno = pubno + " ";
nl--;
}
}
cModel.addElement(pubno + "- " + pubName);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
private void cmdClearActionPerformed(java.awt.event.ActionEvent evt) {
DefaultComboBoxModel cModel = (DefaultComboBoxModel) jComboBox1.getModel();
txtAcno.setText("");
txtBTitle.setText("");
txtAuth1.setText("");
txtAuth2.setText("");
cModel.removeAllElements();
txtPrice.setText("");
txtPages.setText("");
txtEdition.setText("");
txtPDate.setText("");
txtStatus.setText("");
cmdSave.setEnabled(false);
}
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtAcno.setEditable(false);
// Deactivate the Save button when form loads
cmdSave.setEnabled(false);
}
private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new LibDelUI().setVisible(true);
}
/** * @param args the command line arguments */
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LibUI().setVisible(true);
}
});
}
}
7. User Manual

7.1 How to installSoftware:


Hardware Requirement-
 Intel Pentium/Celeron or similar processor based PC at Client/Server end.
 128 MB RAM and 4GB HDD space (for Database) is desirable.
 Standard I/O devices like Keyboard and Mouse etc.
 Printer is needed for hard-copy reports.
 Local Area Network(LAN) is required for Client-Server Installation

Software Requirement-
 Windows 2000/XP OS is desirable.
 NetBeans Ver 5.1 or higher should be installed with JDK and JVM.
 MySQL Ver 6.1 with Library Database must be present at machine.

Database Installation

The software project is distributed with a backup copy of a Database named Library with
required tables. Some dummy records are present in the tables for testing purposes, which can be
deleted before inserting real data. The project is shipped with LIB.SQL file which installs a
database and tables in the computer system.

Note: The PC must have MySQL server with user (root) and password (raj) . If root password is
any other password, it can be changed by running MySQL Server Instance Configure Wizard.

Start Program  MySQL MySQL Server MySQL Server Instance Config Wizard

Provide current password of root and new password as “raj” , this will change the root password.

To install a MySQL database from a dump file ( Lib.sql) , simply follow the following steps.
Step 1: Copy the Lib.sql file in C:\Program files\Mysql\MySql server 5.1\Bin folder.
Step 2: Open MySQL and type the following command to create the dabase named Library.
mysql> create database Library;
Step 3: Open Command Window (Start Run  cmd)
Step 4: Go to the following folder using CD command of DOS.
C:\Program files\Mysql\MySql server 5.1\Bin>
Step 5: type the following command on above prompt -
C:….\bin> mysql -u root -praj Library < lib.sql
This will create a Library databse with required tables.
7.2 Working with SoftwareProject:

The Library Management Program consists of the following logically organised Menu-structure
for the easy functionality. User may choose the menu options for corresponding works.

Publisher:
This menu item gives options to insert, delete, update and access the Publisher record.
Book:
This menu gives options to Insert, delete, modify and delete the Books record. Also the Books
can be Issued and Received to/from members.
Members:
This menu item gives options to insert, delete, update and access the Member’s record.
Report:
This menu provides option to get reports of Issued books, Available books and Members list.
8. References
In order to work on this project titled -LibSys – Public Library Management System, the
following books and literature are refered by me during the various phases of development of
the project.

(1) The Complete Reference Java 2.0


-by Shildit
(2) MySQL, Black Book
-by Steven Holzner
(2) Understanding SQL
– Gruber
(3) http://www.mysql.org/

(4) http://www.netbeans.org/

(5) On-line Help of NetBeans ®

(6) Informatics Practices for class XII


-by Sumita Arora
(7) Together with Informatics Practices
(6) Various Websites of Discussion Forum and software development activities.

Other than the above-mentioned books, the suggestions and supervision of my teacher and my
class experience also helped me to develop this software project.

You might also like