You are on page 1of 81

ANALYSIS AND DESIGN

OF
LIBRARY MANAGEMENT
SYSTEM

[PROJECT REPORT]

COMPILED BY-
NIRUPAMA

GUIDED BY-
Mrs. Shabana Parveen
This is to certify that NIRUPAMA Of STD XII ‘D’ COMMERCE has
completed her project under my guidance and supervision I certify that
this project is in with accordance with the guidelines issued by CBSE.

Date ………..

(Signature)
Teacher in charge
I am thankful to Mrs. Shabana Parveen my Informatics
Practices teacher who has provided requisite
guidance and help for the successful completion of
this project and also last but not the least I would like
to thank all those who directly or indirectly helped
me in the successful completion of
this project

Date…...............

(Signature)
Student

CONTENTS
A. System Description at a glance
B. Problem Description
C. Database Design
D. Project Control Flow
E. Project Output

System Description at a Glance


British Library is a library, which provides reading services to its members. Any person can
become a member of the library by filling a prescribed form and paying appropriate amount of
fees. This membership is given for one- year duration, during which members can avail following
facilities.

 The can get the books and journals for reading /reference.
 They can get books issued, so that they can take them home and return them on or before
due date.

For providing the reading services, library purchases books from the market. When arrived in the
library, they are physically inspected and if they are found in order, they are taken into account,
else they are rejected. Details of the books are noted in the acquisition register. After these
formalities, books can be issued to the readers on their request.
When a member request for a book, librarian searches it in the library according to the
acquisition number and the accession number of the book. If it is available (not issued to other
member) then it is issued to the member and details of the issue are noted down in a register called
issue register.
After reading the book, member returns the book to the librarian. At the time of returning of the
book, librarian should update the library and member data.
Time to time librarian scans through the issue register and finds out list of books, which are issued
and should return in time.
Followings are the activities of librarian of BRITISH library:

 Acquisition of book
 Membership maintenance
 Book issue
 Book return
 Answer management queries

Problem Description

Acquisition of Books
Purchase department of the library purchases various books. After purchase, these books are inspected and
if found in order a unique number called acquisition number is assigned to each book. Purchase
department then sends these books to librarian. Based on the subject, author of the books etc., librarian
assigns a code to the book. This code is called as accession number. He also enters various details regarding
a book in acquisition register. He changes entries of the acquisition register, if some change in book
information takes place. Format of acquisition register is given below:

Acquisition Register

Sl.No Acq.No. Acc.No. Title&Authour Publisher Price&pages Date(P) Status

Membership Maintenance
A person, who wants to be a member of the library, has to fill an application form and given it to the
librarian along with membership fee (minimum 2000) and caution money (500)
Librarian assigns a unique membership number to him and enters the details of this member in
membership register. After some time, if any member wants to reduce or increase his caution money,
librarian makes changes accordingly in the membership modification form. If a member wants to
discontinue in between, librarian strikes off his entry form the membership register and returns the caution
money. Format of membership register is given below:

MEMBERSHIP REGISTER

Sl. No Memb.N Name& Memb.Dat Expiry Membershi Caution


o Address e Date p Fees Money

Librarian issue only one book at a time to a member. A member fills a requisition slip and
requests the librarian to issue the book to him. Format of the requisition slip is checked by the
librarian and the librarian first checks in member register, whether his membership is still
continuing. If not, he does not accept the request else he physically checks for the presence of the
book in the library. If not present, he rejects the request of the member; otherwise he issues the
book to member. Librarian notes down the details in Issue register. Format of issue register is
given below:

ISSUE REGISTER

Sl. No Memb. Acq. Acc. No Book Date Of


No Issued Return
On
BOOK RETURN

When a member return a book the librarian should update the library register (set Status as
‘y,’i.e., available) and member register (set mem- issue as ‘N’, i.e, not issued) properly.

Database Design
The following are the six table with respective fields:

1) Table : Publisher

Field Name Field Type Width Description


PUB_ID Int 4 Publisher ID
PUB_NAME Varchar 30 Publisher Name
PUB_ADDRESS Varchar 40 Publisher Address
PUB_ PHONE 1 Varchar 12 Publisher phone 1
PUB_ PHONE 2 Varchar 12 Publisher phone 2
STATUS CHAR 1 Publisher continue
or not (Y/N). Y-
continue N- Del

MySQL Command

Create table publisher


(pub_id int(4)primary key not null,
pub_name varchar(30 )not null,
pub_ address varchar(40),
pub_phone1 varchar(12)
pub_phone varchar(12)
status char(1));

2) Table : LIB

FIELD NAME FIELD TYPE WIDTH DESCRIPTION


ACC_NO INT 4 ACCESSION NO.
TITLE VARCHAR 30 BOOK TITLE
AUTHOR1 VARCHAR 30 FIRST AUTHOR
AUTHOR2 VARCHAR 30 SECOND AUTHOR
PUB_ID INT 4 PUBLISHER ID
PRICE FLOAT 8 PRICE OF BOOK
PAGES DATE PURCHASE DATE
PDATE INT 4 NO. OF PAGES
EDTION INT 4 PUBLISHED YEAR
(edition)
STATUS CHAR 1 CURRENT STATUS
OF BOOK (Y/N)
MySQL Command

Create table lib


(acc_no int (4),
acq_no int (4),
btitle varchar(30) not null ,
author1 varchar(30),
author2 varchar(30),
pub_id int(4),
price float(/),
pdate date,
pages int(4),
edtion int (4),
FORIGEN KEY(pub_id) REFRENCES publisher(pub_id),
Status char(1));

3) Table : MEMBER

FIELD NAME FIELD TYPE WIDTH DESCRIPTION


MEMB_NO INT 4 Member no
MEMB_NAME VARCHAR 30 Member name
MEMB_ADD VARCHAR 40 Member address
MEMB_PHONE VARCHAR 10 Member phone no
MDATE DATE 10 Membership date
MEDATE DATE 10 Membership expire
date
MFEE NUMBER 8,2 Membership fee
MEM_STATUS CHAR 1 Membership continue
or not (Y/N)Y-
continue N- deleted
MEM_ ISSUE CHAR 1 Either book issued or
not (Y/N) Y- issued
N- not issued

MySQL Command

Create table member


(memb_no int(4) primary key,
memb_name varchar(30),
memb_ add varchar (40),
mdate date,
medate date,
mfee double (8, 2),
mem_status char (1),
mem_issue char (1));

4) Table : MISSUE (this table is for master issue)

Field name Field type Width Description


ACC_NO INT 4 Accession no.
MEMB_NO INT 4 Member no.
IDATE DATE 10 Issue date
RDATE DATE 10 Return date

MySQL Command

Create table missue


( acc_no int(4),
acq _no int (4),
memb_ no int(4),
idate date,
rdate date ) ;

Table : TISSUE(this table is for daily transaction purpose)

Field name Field type Width Description


ACC_NO INT 4 Accession no.
MEMB_NO INT 4 Member no.
IDATE DATE 10 Issue date
RDATE DATE 10 Return date

MySQL Command

Create table Tissue


(acc_no int(4),
memb_no int (4),
idate date,
rdate date );
Project Control Flow
The project contains various form (.java) file with respective menu option. The menu is as:

Publisher Book Member Reporter Quit


Publisher Console Book Console Member Console Available Book Litst Application
Modification Modification Modification Issued Book List
Deletion Deletion Deletion Member List
Record Navigation Book Issued Record Navigation
Book Returned
The following listing shows the java files with respective menu options

Menu Caption Form File Variable Name


Main Library Form Main UI.java
Publisher
Publisher Console pubUI.java mnuPub
Modification PubEditUI.java mnuPMod
Deletion PubDelUI..Java mnuPDel
Record Navigation PubNavUI.java mnuPNav
Book
Book Console LibUI.java mnuLib
Modification LibEditUI.java mnuLibEdit
Deletion LIbDelUI.java mnuLibDel
Book Issue IssueUI.java mnuIssue
Book returned ReturnUI.java mnuRetun
Member
Member Console MemUI.java mnuMemb
Modification MembEditUI.java mnuMMod
Deletion MemDelUI.java mnuMDel
Record Navigation MemNavUI.Java MnuMNav
Report
Available book List ABListUI.java mnuABList
Issued Book List IBListUI.java mnuIBList
Member List MListUI.java mnuMList
Quit
Application mnuQuit
Program output

Library Main Menu Screen (MainUijava)

Source Code : MainUI.java


private void mnu PubAction Performed(java .awt.event.Action Event evt) {
//this.setVisible(false);
new pubUI( ).setVisible(true);
new pubUI ( ).getAlignmentX( );
}
private void mnuQuitActionPerformed(java.awt.event.ActionEvent evt) {
System. exit(O);
}
private void mnuPModActionPerformed(java.awt,event.ActionEvent evt) {
new PubEditUI( ).setVisible(true);
}
private void mnuPDelActionPerformed(java.awt.event.ActionEvent evt) {
new PubDeIUI( ).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 jMenultem5ActionPerformed(java.awt.eventActionEvent evt) {
new MembUI( ).setVisible(true);
}
private void jMenultem6ActionPerformed(java.awt.event.ActioflEvent evt) {
new MembEditUl( ).setVisible(true);
}
private void mnuMDel ActionPerformed(java.awt.event.ActioflEvent evt) {
new MembDeIUI( ).setVisible(true);
}
private void mnuMNavActionPerformed(java.awt.event.ActionEvent evt) {
new MembNavUI( ).setVisible(true);
}
private void mnulssueActionPerformed(java.awt,event.ActionEvent evt) {
new IssueUI( ).setVisible(true);
}
private void mnuReturnActionperformed(java.awt.event.ActionEvent evt) {
new ReturnUl( ) .setVisible(true);
}
private void mnuABListActionPerformed(java.awt.event.ActionEvent evt) {
new ABLIstUI( ).setVisible(true);
}
private void mnulBListActionPerformed(java.awt.eventActionEvent evt) {
new IBListUI( ).setVisible(true);
}
private void rnnuMListActionPerformed(java.awt.event.ActionEvent evt) {
new MListUT( ).setVisible(true);

Publisher Entry (pubUl.java)

Source Code :
pubULjava
Used Class/Packages
import java.sql.*;
import javax.swing.]OptionPane;

Exit: ActionEvent Procedure

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


this. setVisib le (false)
new MainUI ( ).setVisible(true);
}
Form load procedure:
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtPno.setEditable(false);
// Deactivate the Save button when form loads cmdSave.setEnabled(false);
}

New: ActionEvent Procedure


private void cmdNewActionPerformed(java.awtevent.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’,reeta);
Statement stmt = null;
ResultSet rs = null; // ResultSet for publisher table.
String SQL = SELECT * FROM publisher’; stmt = con.createstatement( ); // Connection string
for ResuitSet - rs.
rs = stmt.executeQuery(SQL);
int pno = 1;
int PID = 0;
while (rs.next( )) {
PID = rsgetlnt(“pubid”);
pno++;
}
P1 D + +; 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( );
}
}

Save : ActionEvent Procedure

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”,”reta”);
Statement stmt = null;
ResuitSet rs = null;
String SQL = ‘SELECT * FROM publisher”;
stmt = con.createStatement( ) ;
rs = stmt.executeQuery(SQL);
int Pno = Integer. parselnt(txtPno. getText( ));
String PName = txtPName.getText( );
String PAdd = txtPAdd,getText ( ) ;
String Pphl = txtPhl.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 == 3OptionPane.YES_OPTION) {
String strSQL= “INSERT INTO Publisher(pub_id, pub pub address, :
pub_phone2, status) VALUES (“+(Pno)+”, “+(PName)+”, “+(PAdd “+(Pphl)+”,
“+(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( ));
}

Clear ActionEvent Procedure

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


txtPno.setText(“”);
txtPName.setText(“”);
txtPAdd .setText(“”);
txtPhl .setText( “ “);
txtPh2 .setText( “ “);
cmdSave.setEnabled(false);
}
}
Edit__j ActionEvent Procedure
private void cmdEditActionPerformt d(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new PubEditUIQ.setVisible(true);
}
Source CODE : PubEdit.java
Used class/packages:
import java.sql.* ;
import javax.swing.JoptionPane;
import javax.swing.DefaultListModel;

From load vprocedure :

private void fromWindow GainedFocus(java.awt.event evt) {


txtPno.setText(false);
//Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModle dModel = (DefaultListModel) jListl.getModelQ;
// Method toadd elements into jList1 control
dModel.clear( );
try{
Class.forName(“com.mysql.jdbc.Driver”);
Connection con = (Connection)
DriverManager.getConnection
(“jdbc:mysql://localhost:3306/Library”,”root”,”reta”);
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(pubid”);
String PName = rs.getString(pub_name);
//To make the publisher no. as 4 digit because we wiil extract 4 digit from list value
// in mouse click event.

if(Pno.length( ) <4)
{
int x Pno.length( );
int nl = 4-x;
while( nl>O){
Pno = Pno + “”;
nl- -

}
dModel.addElement(Pno +”-“ + PName);
}
jListl .setModel(dModel);
con.close( );
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage( ));
e printStacklrace( );
}
Mouse click event Procedure:
private void jListlMouseClicked(java .awt. event. MouseEvent evt) {
// getSelectedValue() method extracts the current cursor location value into a variable
String MPub = (String) jListl.getSelectedValue( );
// Extract the first 4 characters as publisher ID into a variable
String PubN =MPub.trim( ).substring(O, 3);
String query = ‘SELECT * FROM Publisher WHERE pub_id = “+ PubN +”;”;
try{
Class.forName(“com.mysql.jdbc.Driver”).newInstance( );
Connection con = (Connection)
DriverManagergetConnection( “jdbc:mysql://localhost:3306/Library”,”root”,”reeta”);
// Create SQL statement and execute query.
Statement stmt = con.createStatement( );
ResultSet rs = stmt.executeQuery(query) ;
if (rs.nextO) {
//PubN = rs.getString(”pub_no”);
String PubName = rs.getString(“pub_name”);
String PubAdd = rs.getString( “pub_address”);
String PubPhl = 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);
txtPhlsetText(PubPhl);
txtPh2.setText(PubPh2);
txtStatus.setText(PStatus):
txtPrio.setEditable(false);
// Close the operational object for Student
con .close( );
stmt.close( );
rs.cloe( );
}else{
JOptionPane.showMessageDialog(null , “Record does not found in publisher
table”);
}
} catch (Exception e) {
JOptionPaneshowMessageDialog(this, e.getMessage( ));
}
}

Exit J ActionEvent Procedure

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


this.setVisible(false);
//new MainUI( ).setVisible(true);
}
Update :ActionEvent Procedures

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


try{
// Connect to MySQL database
// Dont forget to import the two packages
// import javasql.*;
// import javax.swingJOptionPane;
C!ass.forName(”com .mysql.jdbc. Driver”);
Connection con = (Connection)
DriverManagergetConnection(”jdbc: mysql://localhost: 3306/Library”,”root”,”reeta”);
Statement stmt = null;
ResultSet rs = null;
String SQL = ‘SELECT ‘ FROM Publisher”;
stmt := concreateStatemento;
rs stmt.executeQuery(SQL);
int pno = Integer.parselnt(txtPno.getText( ) :rim());
String PubName = txtPName.getText( );
String PubAdd = txtPAddgetText ();
String PubPhl = txtPhlgetText();
String PubPh2 = txtPh2getText();
String PStatus = txtStatus.getText();
String strSQL= “ Update publisher set pub_name =‘‘+(PubName)+””,
pub_address = “ (PubAdd)+” pub_phonel = “+(PubPh1)+”,
pub_phone2 = “+(PubPh2)+”, status = “+(PStatus)+” where pub_id + (pno);
int rowsEffected = stmt.executeUpdate(strSQL);
if (rowsEffected == 0)
JOptionPaneshowMessageDialog(this, “Record does not exists”);
else
JOptionPane.showMessageDialog(this,”Record modified”);
con.close( );
stmt.close();
rs.ciose();
} catch (Exception e) {
JOptionPaneshowMessageDialog(this, e.getMessage());
}
}
Publisher Delition (pubDelUI.java)
Source Code: PubDelUijava
Used Class/Packages:
import java.sql.*;
import javax.swing .JOptionPane;
import javax.swing.DefaultListModel;
Global Variables :
Statement stmt = null;
ResultSet rs = null;
String SQL “SELECT * FROM Publisher”;
Delete: ActionEvent Procedures
private void cmdDeleteActionPerformed(java awt.event.ActionEvent evt) {
try{
Class.forName(‘com.mysql.jdbc.Driver’);
Connection con = (Connection)
DriverManager.getConnection(”jdbc:mysql://localhost:33O6/Library”,”root”,”reeta”);
stmt = concreateStatement();
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 == JOptionPaneYES_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(”’);
txtPh 1 setText(””);
txtPh2setText(“”);
txtStatus.setText(”);
txtPno.setEditable(true);
}
} catch (Exc e) {
JOptionPane.showMessageDialog(nuIl, “Unable to delete”);
}
}
} catch (Exception e)
JOptionPane.showMessageDialog(this, e.getMessage());
}

Exit : ActionEvent Procedure

private void cmdExitActionPerformed(java awt.event,ActionEvent evt) {


this.setVisible(false);
//new MainUI( ).setVisible(true);
mouse click event Procedure :
private void jListlMouseClicked(java.awt.event.MouseEvent evt) {
// getselectedValue() method extracts the current cursor location value into a variable
String MPub = (String) justl .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 “ + ubN + “;“;
try{
// Connect to MySQL database
// Dont forget to import the two packages
// import java.sql.*;
// import javax.swingjOptionPane;
CIass.forName(”com.mysql.jdbc.Driver”).newInstance( );
Connection con = (Connection)
DriverManager.getConnection(”jdbc: mysql ://localhost: 3306/Library”,
“root”,’reeta”);
// Create SQL statement and execute query.
stmt = con.createStatement();
rs = stmt.executeQuery(query);
if (rs.next( )) {
//PubN = rs.getStriny(”pub_no’);
String PubName = rs getString( pub_name ),
String PubAdd = rs.getString(”pub_address”);
String PubPhl = rs.getString(”pub_phonel”);
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);
txtPhl.setText(PubPhl);
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( ));
}
}

From load procedure:


private void formWindowGainedFocus(java awt event WindowEvent evt) {
txtPno setEditable(false),
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListModel) jListl .getModel( );
// Method to add elements into jListl control
dModel.clear( );
try{

Class.IorName(’com.mysql.jdbc. Driver”);
Connection con (Connection)
DriverManager.getConnection(“jdbc: mysql://localhost/3306/Library”,”root” ,
“reeta”);
stmt = con.createStatement( );
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String Pno = rs.getString(“pub_id”);
String PName = rs.gctString(“pub_name”);
// To make the publisher no. as 4 digit because we will extract 4 digit
fromlist value
//in mouse click event.
if (Pno.length() < 4)
{
int x = Pno.length();
intt ni = 4 - x;
while (nl > 0){
Pno = Pno +” ”;
nl--;
}
}
dModel.addElement(Pno + + PName);
}
jList1.setModel(dModel);
con.close();
} catch (Exception e) {
J0ptionPane.showMessageDialog(this,e.getMessage( ) );
e. printStackTrace( )
}
}
Publisher Navigation (PubNavUI.java)

Source Code: PubNavUijava


ussed Class/Packages
import java,sql.*;
import javax.swing.JOptionPane;
Global Variables and a method
Statement stmt = null;
ResultSet rs = null;
String SQL “SELECT * FROM publisher”
public void disable textfields() {
txtPno.setEditable(false),
txtPName.setEditable(false);
txtPAdd .setEditable(false);
txtPhl .setEditable(false);
txtPh2.setEditable(false),
txtStatus . setEditable(false);
}
First ActionEvent Procedures
private void cmdFirstActionPerformed(java .awt.event.ActionEvent evt)
{
{
Class.forname(“com.mysql.jdbc.Driver”);
Connection con = (Connection)
DriverManager.getConnection(”jdbc: mysql://localhost:3306/Library”,”root’,”reeta”);
if (rs.first()) {
String PubN = rs.getString(”pubid”);
String PubName = rs.getString(”pub_name”);
String PubAdd = rs.getString(’pub address’);
String PubPhl = rs.getString(”pub phone1”);
String PubPh2 = rs.getString(”pub phone 2”);
String PStatus = rs.getString(”status”);
// Displaying the contents in respective text boxes.
txtPno.setText(PubN);
txtPName,setText(PubName);
txtPAdd .setText(PubAdd);
txtPh 1 setText( PubPh 1);
txtph2setText(PubPh2);
txtStatus.setlext(PStatus),
cmd First. setEnabled (false);
cmdNext.setEnabled(true);
cmd Prev. setEnabled (false);
cmdLast.setEnabled(true);
} else {
cmd First. setEnabled (false);
cmd Next. setEnabled (false);
cmdPrev.setEnabled(false);
cmdLast.setEnabled(false);
JOptionPane.showMessageDialog(this, “Rhere is no record in table”, “Student”,O);

}
}catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage( ));

Next ActionEvent Procedures


private void cmdNextAction Performed(java .awt. event.ActionEvent evt) {
try{
Class.forName(”com.mysql.jdbc.Driver”);
Connection con (Connection)
DriverManager.getConnection(”jdbc: mysql://localhost: 3306/Library’ ,“root”,”
reeta”);
if (rs.next()) {
String PubN = rs,getString(”pub_id”);
String PubName = rs.getString (“pub name”);
String PubAdd = rs.getStrinq(”pub address”);
String PubPhl = 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);
txtPh 1 .setText(PubPh 1);
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( ));
}
}
Exit ActionEvent Procedure
private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {
this,setVisible(false);
}
Previous ActionEvent Procedures
private void cmdPrActionPerformed(java .awt.event.ActionEvent evt) {
try{
Class.forName(”com.mysql.jdbc.Driver”);
Connection c = (Connection)
DriverM iager.getConnection(”jdbc: mysql://localhost:3306/Library”,”root”;”reeta”);
if (rs.previou ( )) {
String PubN = rs.getString(”pub_id”);
String PubName = rs.getString(”pub_name’);
String PubAdd rs.getString(”pub_address”);
String PubPhl = rs.getString(”pub_phonel”);
String PubPh2 = rs.getString(”pubphone2”);
String PStatus = rs. getString(”status”);
// Displaying the contents in respective text boxes.
txtPno.setText(PubN);
txtPName,setText(PubName);
txtPAdd.setText(PubAdd);
txtPh 1 .setText( PubPh 1);
txtPh2.setText(PubPh2);
txtStatus.setText(P cmdFirst.setEnabled(true);
cmdNext.setEriabled(true);
cmdPrev.setEnabled(true);
cmdLast.setEnabled(true);
} else {
cmdPrev.setEnabled(false);
JOptionPane.showMessageDialog(this, You are at first position”, “Student”,O);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage( ) );
}

Last Action Event Procedures


Drivate void cmdLastActionPerformed(java .awt.eventActionEvent evt) {
try{
Class.forName(”com mysql.jdbc. Driver’);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql://localhost:3306/Library”,’root” );
if (rs.last( )) {
String PubN rs.getString(”pubjd”);
String PubName = rsgetString(”pub_name”);
String PubAdd = rs.getString(”pubaddress”);
String PubPhl = 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);
txtPh 1 .setText(PubPhl);
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”,O);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
FROM load procedure
private void formWindowGainedFocus(java .awt.event. WindowEvent evt) {
disable_textfields();
try{
Class.forName(”com .mysql,jdbc. Driver”);
Connection con = (Connection)
DriverManager.getconnection(’jdbc: mysqi://localhost:3306/Library”,root”,’reeta”);
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
if (rsflrst( )) {
String PuhN = rs.getString(“pub_ id”);
Strnig PubName = rs.getString(“pub_ name”);
String jbAdd rsgetString(pub _address”);
String PubPhl rsgetString(pub_ phone1’);
String PuoPh2 = rs.getString(”pub_ phone2”)
String PStatus = rs.getString(“status”);
// Dispiay the contents in respecdve text boxes.
txtpno.setText( PubN);
txtPNarne.setText(PubNarne);
txtPAdd setText(“PubAdd”)
txtPhl.setText(PubPh 1);
txtph2.setText(PuhPh2);
txtStatus.setText(PStatus);
cmdFirstsetEnahled(false);
cmdNextsetEnabled(true);
cmdPrev.setEnabled(false);
cmdLast.setEnabled(true);
}
else{
cmd First. setEnab led (false);
cmd Next setEnabled (false);
cmdPrev.setEnabled(false);
cmd Last. setEnabled(false);
JOptionPane.showMessageDialog(this, “Rhere is no record in table”,
“Student”,0);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage( ));
}
}

Book Console:( LibUI.java)

Source Code: LibUI.java

used Class/Packages
import java.sql.*;
import javax.swing.]OptionPane;
irnport javax,swing.DefaultListModel;

GIobaL Variables:

//for table Lib


statement stmt = null;
ResultSet rs = null;
STRING SQL = SELECT * FROM Lib”;
// for table Publisher
satement stmtl = null;
ResultSet rsl = null;
String SQL1 SELECT * FROM publisher;
Exit : ActionEvent Procedure:
private void cmdExitActionperformed(java.awt.eveflt.ActiOflEVeflt evt) {
this. set Visible (false)
}
Edit :ActionEvent Procedure:
private void crndEditActionPerforrned(java.awt.event.ActionEVent evt) {
this.setVisible(false);
new LibEditUI( ).setVisible(true);
}
Save :ActionEvent Procedure
private void cmdSaveActionPerformed(java.awt.event.ActiOnEvent evt) {
try{
Class. forName( corn. mysql .jdbc. Driver’);
Connection con = (Connection)
DriverManager.getConnection(jdbc: mysql ://localhost: 3306/Library”,”root”,°reeta’);
stmt = con.createStatement( );
rs = stmt.executeQuery(SQL);
int Acno = Integer.parselnt(txtAcno.getTextO.trim( ));
String bTitle = txtBTitle.getText( );
String Auth1 = txtAuth1.getText( );
String Auth2 = txtAuth2.getText( );
// Creating a String object pNarne
String pName = (String) jComboBoxl .getSelectedltem( );
// Extract the first 4 characters as publisher number into a variable
String PubNo = String.valueOf(pNarne.substring(O, 3).trim( ));
int pno = Integer.parselnt(PubNo);
jLabellO.setText(+pno);
float Price = Float.parseFloat(txtPrice.getText( ));
int pages = Integer.parselnt(txtPages.getText( ));
int edition = Integer.parselnt(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, authorl, author2, pub_id,
price, pdate, pages, edition, status)
VALUES (“+(Acno)+”, “+(bTitle)+”, “+(Authl)+ ‘“+(Auth2)+”, “+ — “+(Price)+”, ‘“+(Pdate)
+” “+(pages)+”, “+(edition)+”, ‘“+(BStatus)+”);
int rowsEffected = stmt.executeUpdate(strSQL);
]OptionPane.showMessageDialog(this, Record added successfully into Lib table”);
}
cmdSave.setEnabled(false);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage( ));
}
}
‘New ActionEvent Procedure
private void cmdNewActionPerformed(java.awt.event.ActionEvent evt) {
// Activate the Save button when New button pressed
cmdSave.setEnabled(true);
DefaultComboBoxModel cModel = (DefaultComboBoxModel) jComboBoxl .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( mysql://localhost: 3306/Library”, “root”, “reeta”);
stmt = con.createStatemento;
// Connection string for ResultSet - rs.
rs = stmt.executeQuery(SQL);
int acno=0, ACNO = 0;
// To generate automatic accession no.
while (rs.next( )) {
ACNO = rs.getlnt(”acc_no”);
}
ACNO+ +;
acno = ACNO;
txtAcno.setText(Integer.toString(acno));
stmt = con.createStatemento; II To list publishers in jComboBoxi component
rsl= stmt1.executeQuery(SQL1);
while (rs1.next( )) {
String pubno = rs1.getString(“pub_id”);
String pubName = rsl.getString(”pub name”);
// To make the p iblisher no. as 4 digit because we will extract 4 digit from list
// in mouse click event
txtStatus.setText( “Y”); // Because it is a new book, when it wili be issue,
// it’s status will be N.
if (pubno.length( < 4) {
int x = pubno.length
int nI = 4 -
while (nI > 0) {
pubno = pubno + “”;
nl--;
}
}
cModel.addElement(pubno + “- “ + pubName);
}
} catch (Exception e) {
J0ptionPane.showMessageDialog(this,e.getMessage( ));
e.printStackTrace( );
}
}

Clear : ActionEvent Procedure:


private void cmdClearActionPerformed(java.awt.event.ActionEverit evt) {
DefaultComboBoxModel cModel = (DefaultComboBoxModel) jComboBoxl.getModel( );
txtAcno .setText(””);
txtBTitle.setText(”’);
txtAuth 1 .setText(’”);
txtAuth2.setText(””);
cModel. removeAllElements();
txtPrice setText(“”);
txtPages.setText txtEdition.setText();
txtPDate.setText( “”);
txtStatus. setText(”);
cmdSave setEnabled (false);
}
Form load procedure
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtAcno.setEditable(false);
// Deactivate the Save button when form loads
cmd Save setE nabled (false);
}

Delete : ActionEvent Procedure:

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


this.setVisible(false);
new LibDelUI( ).setVisible(true);

Book Modification (LibEditUijava)


Source Code: LibEditUijava
Used Class/Packages
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.DefauftListModel;
import javaxswing.DefaultComboBoxMOdeI;

GlobaI Variables

//for table Publisher


Statement stmt = null;
ResultSet rs1 = null;
String SQL1 = “SELECT * FROM publisher;
Statement stmt = null;
ResultSet rs = null;
String SQL = ‘SELECT * FROM Lib”;

Update :ActionEvent Procedures

private void cmdUpdateActionPerformed(java.awteveflt.ActionEvent evt) {


try {
Class.forName(”com .mysql.jdbc.Driver”);
Connection con = (Connection)
DriverManager.getConnectiofl(’jdbC mysql://localhost:3306/Library”,”root”,”reeta”);
stmt = con.createStatement( );
rs = stmt.executeQuery(SQL);
int Acno = Integer.parse
String bTitle = txtBTitle. getText( );
String Auth1= txtAuthl.getText( );
String Auth2 = txtAuth2,getText();
// Creating a String object pName
String pName = (String) jComboBox.getSelectedltem( );
// Extract the first 4 characters as publisher number into a variable
String NPubNo = String.valueOF(pName.substrinb(0,3)trim( ));
int Npno = Integer.parseInt(NPubNo);
int PID = Integer.pars .parseInt(txtPID);
if(Npno != PID)
PID = Npno;
float Price = Float.parseFloat(txtPrice.getText( ));
int pages = Integer.parselnt(txtPages.getText( ));
int edition = Integer. parseInt(txtEdition .getText());
String Pdate = txtPDate .getText( );
String BStatus = txtStatus. getText();
String strSQL = “Update Lib set btitle =‘‘+(bTitle)+”’, authori = “+(Authl)— auth = “+
(Auth2)+”, pub id = ‘+(PID)-1-”, price= “+(price)+”pdate = “+(Pdate)+’’, pages = “-h(pages)+ “,
edition = +(edition)+, status = “+(BStatus)+” where acc no = “ + (Acno);
int rowsEffected = stmt.executeUpdate(strSQL);
if (rowsEffected = = 0)
JOptionPane .showMessageDialog(this, ‘Record does not exists”);
else

JOptionPane,showMessageDialog(this,’Record modified);
catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage( ));
}
}
Form load procedure
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtAcno .setEditable(false);
txtPID .setEditabie(false);
txtStatus. setEdita bie(false);
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListMod jListl .getModel();
// Method to add elements into jListl control
dModeLclear( );
try {
Class. forN ame( corn mysqi.jdbc. Driver’)
Connection con = (Connection)
DriverManager.getConnection(“jdbc:mysql://localhost:3306/Library
“,”root”,reeta);
stmt = con.createStatement();
rs =strntexecuteQuery(SQL);
while (rs,next()) {
String Ano = rs.getString(“acc_no”);
String BTitle = rs.getStr:ng(“BTitle”);
// To make the Accession no. as 4 digit because we will extract 4 digit from list value
//in mouse click event.
if (Ano.length() < 4)
}
int x = Ano.Iength();
int nl = 4 - x;
while (ni > O){
Ano=Ano± “;
DModeLaddElement(Ano + “- + BTitle);
}
jListl .setModel(dModel);
// To list the publisher id and name into JComboBoxl.
DefaultComboBoxModel cModel = (DefaultComboBoxModel) jComboBoxl.getModelQ;
cModeLremoveAl(Elements();
stmtl = con.createStatement(); // To list publishers in iComboBoxi component
rsl = stmtl.executeQuery(SQL1);
while (rsl.next()) {
String pubno = rsl.getString(“pub_id”);
String pubName = rsl.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,
// its status will be N.
if (pubno.length() < 4)
{
int x = pubno,length();
int nl = 4 - x;
while (nl >0){

pbno = pbno+””;
nl--;
}
}

cModel.addElement(Pbno+”-“+Pubname);
}
}catch (Exception e){
JOptionPane.ShowMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
Exit ActionEvent Procedure
private void cmdExitActionPerformed(java .awt. event.ActionEvent evt) {
this.setVisible(false);
}
Mouse click event Procedure
private void jListlMouseClicked(java.awt.event.MouseEvent evt) {
// getSelectedValue() method extracts the current cursor location value
String MBook = (String) jListl.getSelectedValue(),
// Extract the first 4 characters as Accession number into a variable
String Acno =MBook.trim().substring(O, 3);
String query = “SELECT * FROM Lib WHERE accno = + Acno + “;”;
try {
Class .forNa me( corn mysql.jdbc. Driver’) newlnstance();
Connection con = (Connection)
DriverManager.getConnection(”jdbc://localhost: 3306/Library”,”root”,”reeta”);
// Create SQL statement and execute query.
stmt = con.createStatement();
rs stmt.executeQuery(query);
if (rs,nextQ) {
String bTitle = rs.getString(”btitle”)
String Authl = rs.getString(”author”)
String Auth2 = rs.getString(’author2);
String PID = rs.getString(’pubjd’);
String Price = rs.getString(’price”);
String PDate = rs.getString(”pdate);
String pages = rs.getString(”pages”)
String edition = rs.getString(’edition”)
String PStatus = rs. getString(’status’);
// Displaying the contents in respective text boxes.
txtAcno.setText(Acno);
txtBT itle.setText(bTitle);
txtAuth 1 .setText(Auth 1);
txtAuth2.setText(Auth2);
txtPID.setText(PID);
txtPrice. setText( Price);
txtPD txtPages. setText( pages);
txtEd ition .setText(edition);
txtStatus.setText( Status);
// Close the operaional object for Student
con.close();
stmt.close();
rsclose();
} else {
JOptionPane.showMessageDialog(null, “Record does not found in Student table’);
}
} catch (Exception e) {
JOptionPane.showMessageDiaIog(th e.getMessage());
}
}
Book Deletion( LibDelUl.java)

Source Code: LibDelUl.java


Used Class/Packages
import java.sql.*; J
import javax.swing.JOptionPane;
import javax.swing.DefaultListModel;
Global Variables
Statement stmt = null;
ResultSet rs = null;
String SQL = “SELECT * FROM lib”;
Delete ActionEvent Procedures
private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {
try{

Class .forName(”com .rnysql.jdbc.Driver”);


Connection con = (Connection)
DriverManager.getConnection(”jdbc: mysql://localhost: 3306/Library”,’root”,”reeta’);
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
int Ano = Integer.parsolnt(txtAcno.getText().trim());
// Steps to confirm deletion
int opt = JOptionpane.showConfirmDialog(null,”Are you sure to delete this record ?“);
if (opt == JOptionPane,YES OPTION)
{
try{
if (txtStatus.getTextQ.contains(Y))
String strSQL = ‘Delete from Lib where acc_no = “ + (Ano);
int rowsEffected = stmt.executeUpdate(StrSQL)•
if (rowsEffectecd = 0)
JOptionPane.showMessageDialog(this “Record does not exists);
else
{
}
JOptionPane.showMessageDialog(this ‘Record Deleted”);
}
else
JOptionPane. showMessageoiaiog (this,
“Record cannot be deleted, because status is ‘N”);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, “Unable to delete”);
}
}
con.close();
stmt.close();
rs.close();
} catch (Exception e) {
JOptionPane.showMessageDjalog(this e.getMessage());
}
Exit ActionEvent Procedure
private void cmdExitActionPerformed(java .awt. event.ActionEvent evt) {
this.setVisible(false);

Mouse click event Procedure


private void jListlMouseClicked(javaawtevenfMouseEvent evt) {
// getSelectedvalue() method extracts the current cursor location value into a variable
String MBook (String) jListl.getSelectedvalue();
// Extract the first 4 characters as Accession number into a variable
String Acno =‘MBook.trim().substring(o, 3);
String query = “SELECT * FROM Lib WHERE acc_no “ + Acno + “;“;
try{
Class. fo rN a me (“corn. mysq I .jd bc. Driver”) .newI nsta nce();
Connectjon con (Connection)
DriverManager.getConnection(”jdbc: mysql://localhost: 3306/Library”,’root”,”reeta’);
// Create SQL statement and execute query.
stmt = con.createStatement();
rs = stmt.executQuary(query);
if (rsnext()) {
String bTitle = rs. getString( “btitle’);
String Auth 1 = rs.getString(”author1”);
String Auth2 = rs.getString(”author2”);
String PID = rs.getString(”pubid”);
String Price rs.getString(”price”);
String PDate = rs.getString(“pdate”);
String pages = rs.getString(’pages”);
String edit = rs.getStrinq(edition”);
String PStatus = rs.getString(”status”)
// Displaying the contents in respecUve text boxes.
txtAcno . setText(Acno);
txtBlitle.setText(bTitle);
txtAuthl.setText(Authl);
txtAuth 2. setText(Auth 2);
txtPl D.setText(PID);
txtPr txtPDate.setText(PDate);
txtPages setText(pages);
txtEdition .setText(edition);
txtStatus .setText(PStatus);
// Close the operational object for Student
con.ciose();
stmt close();
rs.close()
} else {
JOptionPane.showMessageDiatog(nutl, ‘Record does not found in Student table”);
}
} catch (Exception e){
jOptionPaneshowMessageDiatog(this, egetMessage());
}
Form load procedure
private void formWindowGainedFocus(java,awt.event.WindowEvent evt) {
txtAcno.setEditabie(false);
txtPl D . setEd i tab I a (false);
txtStatus .setEditabie(false);
// Creating a ListModeI object dModel to perform DefaultListModel
// method operations
DefaultListModei dModel = (DefauftListModel) jListl,getModel();
/1/ Method to add elements into jListl control
dModel,ciear(),
try
{
Class. fo rN a me (“corn. mysq I .jd bc. Driver”);
Connectjon con (Connection)
DriverManager.getConnection(”jdbc: mysql://localhost:
3306/Library”,’root”,”reeta’);
stmt = con.createStatement()\;
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String Ano = rs.getString(“acc_no”);
String BTitIe = rs.getString(“btitle”);
// To make the Accession no. as 4 digit because we wilt extract 4 digit from
;/ list value in mouse click event.
if (Ano.length() < 4)
{
int x = Ano.length();
i nt nl = 4 - x;
while (nl >0){
Ano = Ano +“”;
nl--;
}
}
dModei.addElement(Ano + - “ + BTitle);
}
jListl .setModel(dModel);
} catch (Exception e) {
JOptionPaneshowMessageDialog(this,e.getMessage());
e. printStackTrace();
}
}

Book Issue (IssueUl.java)

Source Code: IssueUl.java


Used Class/Packages
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.DefaultListModel;
Global Variables
Statement stmt = null;
ResultSet rs = null;
char sti = ‘N’;
char ms = ‘N;
String SQL = “SELECT * FFOM Member WHERE mem_issue = “+st1+” and mem_status =”+
ms +””;
Statement stmtl = null;
ResuitSet rsl = null;
char st = ‘Y’; // Lib table
String SQL1 = SELECT * FROM Lib WHERE status ‘ + St +”;”;
Statement stmt2 = null;
ResultSet rs2 = null;
String SQL2 = “SELECT * FROM Missue;
Statement stmt3 = null;
ResuitSet rs3 = null;
String SQL3 “SELECT * FROM Tissue’;
Mouse click event Procedure
private void jListlMouseClicked(javaawt.event.MouseEveflt evt) {
// getSelectedValue() method extracts the current cursor location value into variable
String MembNo = (String) jListl.getSelectedValue();
// Extract the first 4 characters as Member No into a vanable
String Mno =MembNo.trim( ).substring(O, 3);
String query = “SELECT FROM Member WHERE memb_no “ + (Mno)
try {
Class forNa me( “corn mysql,jdbc. Driver”). newlnstance();
Connection con (Connection)
DriverManager.getConnection(”jdbc: mysq
locahost: 3306/Library”,”root”,”reeta”);
// Create SQL statement and execute query
stmt = con.createStatement();
rs = stmt.executeQuery(query);
if (rs.next()){
String MName rs.getString(”memb_name”);
String MDate = rsgetString(”mdate”);
String MStatus = rs.getString(”mem_status”);
// Displaying the contents in respective text boxes.
txtM No. setText( Mn o);
txtMName.setText(MName);
txtM Date .setText(M Date);
txtMStatus.setText(MStatus);
} else
JOptionPane.showMessageDialog(nuIl, “Record does not found in Member table”);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
Form load procedure
private void formWindowGainedFocus(java ,awt.event.WindowEvent evt) {
txtMNo .setEdita ble(false);
txtM Name setS d ita bI e(false);
txtMDate.setEdita ble(false);
txtMStatus. sefEditable(false);
txtAcno.setEditabie txtBTitie .setEditable(fase);
txtAuth 1 .setEditable(false);
txtPl D setEd ta b I e (false);
txtStatus .setEditable(fa se);
// dModel to perform DefaultListModel for Member
// method operations
DefaultListMode dModel = (DefaultListModel) jListl.getModel();
// Method to add elements into justi control for member
dModel.clear();
try {
Class.forName(
Connection con=(Connection)
DriverManager.getConnection(”jdbc:mysgql://localhost:3306//Library”root”,reeta
”);
// Listing Members
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String Mno = rs.getStri d(”memb_no”);
String MName = rs.getString(”memb name”);
// To make the Member no. as 4 digit because we will extract 4 digit from list
value
// in mouse dick event.

if (Mno.length() < 4)
{
nt x = Mno.Iength();
nt ni = 4 - x;
while (ni >0){
Mno = Mno +””;
ni--;
}
}
dModel.addEiement(Mno -i- “- + MName);
jListl .setM odel( dModel);
// cModei to perform DefaultListModel for Library //
I method operations
DefaultListModel cModel (DefauitListModel) jList2getModelQ;
// Metnod to add elements into jLisd control for Library cModel.clearO,
// Listing books
stmtl = con.createStatement();
rsl = stmtl .executeQuery(SQL1);
while (rslnext()) {
String Ano = rsl.getString( acc_no’);
String BTitle = rsl.getString(”btitie’);
// To make the Accession no. as 4 digit because we will extract 4 digit from list value
// in mouse click event.
if (Anolength() < 4)
{
int x = Ano.Iength();
int ni 4 - x;
while (nl >0){
Ano = Ano +””;
nl--;
}
}
cModel.addElement(Ano + ‘- “ -i- BTitle);
}
jList2setMode (cModel);
} catch (Exception e) {
JOptionpane.showMessageDialog(this,e,getMessage());
e.printStackTrace();
}
}
EXITActionEvent Procedure;
private void cmdExitActionPerformed(java.awt.event.Action eventdf evt){
this.setVisible(false);
}
Mouse click event Procedure
private void jList2MouseClicked(java.awt.event.MousEvent evt){
// getSelectedValue() method extracts the current cursor location value into a variable
String MBook = (String) jList2.getSelectedValue();
// Extract the first 4 characters as Accession number into avariable
String Acno =MBook.trim().substring(0, 3);
String query = SELECT * FROM Lib WHERE acc_no = “ + Acno+”;
try {
Class.forName(”com . mysql.jdbc. Driver”). newlnstance();
Connection con = (Connection) DriverManager.getConnecton(jdbc:mysql://
localhost:3306/Library”,”root”,”reeta”);
/ / Create SQL statement and execute query
. stmt1 = con.createStatement();
rs = stmt 1.executeQuery(query);
if (rsl.next()) {
String bTitle = rs1.getString(“btitle”);
String Auth1 = rs1.getString(“auth1”);
String PID=rsl.getString(“pub_id);
String PStatus = rsl .getString(”status”);
// Displaying the contents in respective text boxes
. txtAcno .setText(Acno);
txtBTitle. setText( bTitle);
txtAuth 1 .setText(Auth 1);
txtPID.setText(PID);
txtStatus.setText(PStatus);
} else {
JOptionPane.showMessageDialog(null, “Record does not found in Libdent table’);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
Issue Action Event Procedure
private void cmdlssueActionPerformed(javaawt.event.ActionEvent evt) {
try {
Class.forName(”com.mysql.jdbc. Driver’);
Connection con = (Connection)
DriverManager.getConnection(“jdbc: mysql://localhost: 3306/Library”,”root’,”reeta”);
// Missue table
stmt2 = concreateStatement();
rs2 = stmt.executeQuery(SQL);
// Tissue table
stmt3 = con.createStatement();
rs3 = stmt.executeQuery(SQL);
int Acno = Integer,parseInt(txtAcno.getText().trim());
i nt Mno = Integer.parseInt(txt Mno.getText().trim());
String idt = tx1Date.getText();
String rdt = idt; // Temporarily assigned for testing purpose
int code = JOptionPane.showConfirmDialog(this,” Are you sure to add?”,
“Confirmation Dialog Box”, JOptionPaneYES_NOCANCELOPTION,
JOptionPane. INFORMATION MESSAGE);
if (code == JOptionPane.YES OPTION) {
// Record updated into Missue and Tissue tables
String strSQL = “INSERT INTO Missue(acc_no, memb_no, date, rdate)
VALUES (“+(Acno)+”, “+(Mno)+”, “+(idt)+”’, ‘“+(rdt)+”)”;
String strSQLl = “INSERT INTO Tissue(acc no, memb_no, date, rdate)
VALUES (“+(Acno)+”, “+(Mno)+”, “- ‘“+(rdt)+”’)”;
stmt2 executeUpdate(strSQL);
stmt3.executeUpdate(strSQLl);

// Change the status as library book issued


char sta ‘N’; /1 Lib table
String strSQLa = “Update Lib set status =“-i-(sta)+” where acc_no = “ + (Acno); stmtl
.executeUpdate(strSQLa);

// Change the status as Member has a book


char stb =’Y’//member table
String strSQLb = “Update Member set mem_issue =“+(stb)+” where memb_no =
+ (Mno);
stmt.executeUpdate(strSQLb);
JOptionPane.showMessageDialog(this, “Record update successfully”);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
Book Return (ReturnUl.java)

Source Code: ReturnUl.java


Used Class/Packages
import java.sql.*;
import javax.swing .jOntionPane;
importjavax.swing. DefaultListModel:
Global Variables
Statement stmt = null;
ResultSet rs = null;
char st1 =‘Y’;
String SQL = SELECT FROM Member WHERE mem_issue = + sti + “;“;

Statement stmtl. = null;


ResultSet rsl = null;
char st = ‘Y; /1 Lib table
String SQL1 = SELECT * FROM Lib WHERE status = “ + St + “‘;“;

Statement stmt2 = null;


ResultSet rs2 = null;
String SQL2 = SELECT * FROM Mlssue’;

Statement stmt3 = null;


ResultSet rs3 = null;
String SQL3 SELECT FROM Tissue’;

Mouse click event Procedures


private void jListlMouseClicked(java.awt.event.MouseEvent evt) {
// getSelectedValue() method extracts the current cursor location value into a variable
String MembNo (String) jListl .getSelectedValue();
// Extract the first 4 characters as Member No into a variable
String Mno =MembNo.trim(0, 3);
String query = SELECT * FROM Member WHERE memb_no = “ + (Mno) + “;“;
try {
Class fo rN a me (“corn. mysq I .jd bc. Driver”). n ewl nsta n ceo;
Connection con = (Connection) DriverManager.getConnection rnysql://
localhost: 3306/Library,”root”,”reeta”);
// Create SQL statement and execute query.
stmt = con.createStaternent();
rs = stmt.executeQuery(query);
if(rs,next()) {

String MName = rs.getString(”rnernb_name”);


String MDate = rs.getString(’mdate’);
String MStatus = rs.getString(‘mem_status’);
// Displaying the contents in respective text boxes.
txtMNo.setText(Mno),
txtM Na me. setText(M Na me);
txtM Date,setText(M Date);
txtMStatus.setText(MStatus);
} else {
JOptionPane,showMessageDialog(null, “Record does not found in Member table”);
// Extrating the Acc_no from Tissue table to find book ezaHs in Lib table
String queryl = SELECT * FROM Tissue WHERE rne no = “ ÷ (Mno) + “;‘;
// Create SQL statement and execute query
stmt3 = con .createStatement();
rs3 = stmt3executeQuery(queryl);
int ACno = 0;
if(rs3.next()) {
ACno = rs3.getint(”acc no);
txtAcn o s etText( String. vaueOf(ACno ));
}
// Extrating the Library details for Acc_no from Lib table
String query2= SELECT * FROM Tissue WHERE rne no = “ + (ACno) + “;‘;
// Create SQL statement and execute query.
Stmt1 = con.createStaternent();
rs1 = stmt1.executeQuery(query);
if(rsl.next()){
BTitie = rsl .getString(btitle”);
Auth = rsi .getString(’authorl”);
txtBTitle setlext(BTitle’);
txtAuth .setText(Auth);
jLabel9.setText(Issued”);
}
} catch (Exception e) {
JOptionPaneshowMessaqeDialog(this, e,getMessage());
}
}

Form load procedure


private void formWindowGainedFocus(java .awt.event.WindowEvent evt) {
txtMNo.setEditable(false);
txtMName. setEditable(false);
txtMDate.setEditabie(faise);
txtMStatus. setEditable(false);
txtAcno .setEditable(false);
txtBTitle. setEditable(false);
txtAuth.setEdtable(false);
// dModel to perform DefaultListModel for Member
// method operations
DefaultListModel dModel = (DefaultListModel) jListl .getModel();
// Method to add elements into jListl control for member
dModei.clear();
try {
Class .forName(com .mysql.jdbc. Driver);
Connection con = (Connection)
DriverManager.getConnectionçjdbc mysql://localhost:
33O6/Library”,”root’,”reeta”);

// Listing Members
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs,next()) {
String Mno = rs,getString(memb no);
String MName = rs.getString(memb_narne);
// To make the Member no. as 4 digit because we will extract 4 digit from list val.
//in mouse click event.

if (Mno.ler ;th() < 4)


{
int x = “Mno.length();
int ni = 4 - x;
while (nI > 0){
Mno=Mno+””;
nl--;
}
}
dModel.addElement(Mno + “- “ + MName ;
}
List 1. setModel (d Model);
} catch (Exception e) {
JOptionPane show Message Dialog (this, e.getM essage( ));
e.printStackTrace();
}
}

Exit ActionEvent Procedure


private void cmdExitActionPerformed(java.awt.event.ActionEveflt e
this. SetVisible(false);
}

Return ActionEvent Procedure

private void cmdReturnActionPerformed(java.awt.eveflt.ACtiOflEveflt evt) {


try{
Class . fo rNa me( ‘corn . mysql.jd bc D river’)
Connection con = (Connection)
DriverManager.getConnection(jdbc: mysqi ://localhost: 3306/Library’ :o ,‘reeta
// Missue table
int Mno = 0, Acno = 0;
Mno = Integer.parselnt(txtMNo.getTexto.trimO);
Acno = Integer.parse
1/ Steps to confirm return
mt opt = JOptionPane.showConfirmDialog(null, Are you sure to return this book ?“); if
(opt == JOptionPane.YES_OPTION)
{
String strSQLr = “Delete from Tissue where memb_no = “ + (Mno); stmt3
.executeUpdate(strSQLr);
// Change the status as library book issued
char sta = ‘Y’; // Lib table
String strsQLa = Update Lib set status =“+(sta)+” where acc_no = “ + (Acno);
stmtl .executeUpdate(strSQLa);
// Change the status as Member has a book
char stb = ‘N’; // Member table
reeta ) String strSQLb = ‘Update Member set mem issue =‘‘+(stb)+” where
memb_no =
+ (Mno);
stmt.executeUpdate(str
JOptionPane.showMessageDialog(this, “Thanks for returning book);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
Member Entry (MembULjava)

Source Code: MembULjava


Used Oass/Packages
import java.sqL
import javax.swing.JoptionPane;

Global Variables :
Statement stmt = null;
ResuitSet rs null; // ResuitSet for publisher table.
String SQL = ‘SELECT * FROM Member;
ActionEvent Procedures
private void cmdClearActionPerformed(java awt.event.ActionEvent evt) {
txtMNo.setText(”);
txtMName.setText(””);
txtMAdd.setText(“”);
txtMPh.setText(’”);
txtMDate.setText(“”);
txtMFee.setText(“”);
txtMStatus.setText(“”);
cmdSave.setEnabled(false);
}
Edit ActionEvent Procedure
private void cmdEditActionPerformed(java.awt.event,Act evt) {
this.setV ible(false);
new MembEditUI().setVisible(true);
}
Exit ActionEvent Procedure
private void cmdExitActic Performed(java.awt.evootActionEvent evt) {
this.setVsible(false);
}
save ActionEvent Procedure

private void cmdSaveActionPerformed(java.awt.eveflt.ActionEvent evt) {


try{
Class.forName(”com.mysql.jdbc. Driver);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:/:iocalhost:3306/Library’,’root”,”reeta”);
stmt = con.createStatement(),
rs = stmt.executeQuery(SQL);

int Mno = Integer.parselnt(txtMNo.getText());


String MName = txtMName.getText();
String MAdd = txtMAdd.getText();
String MPh1 = txtMPh.getText(),
String M Date = txtM DategetText();
// This is temporarily assigned same as membership date
String MEDate = txtMDate
double MFee = Double.parseDouble(txtMFee.getText());
char MStatus = ‘Y’; // Member status is Y
char Mlssue ‘N’; // Book issue status is N
mt code = JOptionPanc.showConfirmDialog(this, “Are you sure to add?”,
“Confirmation Dialog Box”, JOptionPane.YES_NO_CANCEL_OPTION,
JOption Pane IN FORM ‘TION MESSAGE);
if(code = = JOptionPane.YES_OPTION) {
String strSQL = ‘INSERT INTO Member(memb_no, memb name, memb_add,
memb phone. mdate, medate, mfee, mom_status, mem issue)
VALUES (“+(Mno)+”, “+(MName)+”, “+(MAdd)+”, “+(MPhl)+”, “+(MDate)+”,
‘“+(MEDate)+’ “+(MFee)+”, “+(MStatus)+”, “+(Mlssue)+”)”;
int rowsEffected = stmt.executeUpdate(strSQL);
JOptionPane.showMessageDiaiog(this, “Record added successfully into Member table”);
}
cmdSave.setEnabled(false);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
New ActionEvent Procedure
private void cmdNewActionPerformed(java.awt.event.ActionEvent evt) {
txtMStatus.setText(”Y”);
// 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”,”reeta”);
stmt = con.createStatement(); // Connection string for ResultSet - rs.
rs = stmt nt MNO=O, Mno = 0;
while (rs.next()) {

MNO = rs.getlnt(“memb_no”);
MNO++;
Mno = MNO;
txtMNo.setText(lnteger.toString(Mno));
txtMName.setFocusable(true);
} catch (Exception e)
JOptionPane show Message Dialog (this, e.getM essage( ));
e.printStackTrace();
}
}

Form load procedure:


private void formWindowGainedFocus(java.awt.event.W evt) {
txtM No. setEditable (false);
txtMStatus.setEditable(false);
// Deactivate the Save button when form loads
cmdSave.setEnabled(false);
}
private void cmdDelAct evt) {
th is . set Visible (false)
new MembDelUIO.setVisible(true);
}
Member Modification (MembEditUijava)

Source Code: MembEditUijava

Used Class/Packages
import java.sql*;
import javax.swing.JOptionPane
import javax.swing.DefaultListModel;

Global Variables

Statement stmt = null;


ResultSet rs = null;
String SQL = ‘SELECT * FROM Member’;
Exit ActionEvent Procedure

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


this.setVisible(false);
}

Update ActionEvent Procedures

private void cmdUpdateActionPerformed(java.awt.event.ActionEvent e.: :


try {
Class.forName(”com. mysql.jdbc. Driver’);
Connection con = (Connection)
DriverManager.getConnection(”jdbc: mysql://localhost:
3306/Library”,”root”,”reeta”);
stmt con.createStatement();
rs = stmt.executeQuery(SQL);
int Mno = Integer. parseInt(txtMNo.getText() .trim());
String MName = txtMName.getText();
String MAdd = txtMAdd .getText();
String MPh1 = txtMPh.getTex();
String M Date= txtM Date. getText();
// This is temporarily assigned same as membership date
String MEDate = txtMDate.getText ();
double MFee = Double.parseDouble(txtMFee.getText());
char MStatus = ‘Y’; // Member status is Y
String strSQL = ‘Update Member set memb_name =“+(MName)+’,
mernb_add = “+(MAdd)+”’, memb phone =
mdate = ‘“+(MDate)+” mfee = “+(MFee)+” where memb_no = + (Mno);
int rowsEffected = stmt.executeUpdate(strSQL);
if (rowsEffected = = 0)
JOptionPane.showMessageDialog(this, Record does not exists);
else
JOptionPane.showMessageDialog(this,’Record modified’);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessageO);
}
}
Mouse click event Procedure
private void jListlMouseClicked(java.awt.event.MouseEvent evt) {
// getSelectedValue() method extracts the current cursor location value into a variable
String MembNo = (String) jListl.getSelectedValue();
//Extract the first 4 characters as Member No into a variable
String Mno =MembNo.trim().substring(0, 3);
String query = “SELECT * FROM Member WHERE memb_no = “ + (Mno) + “;“;
try {
Class.forName(”com.mysql.jdbc.Driver’).newlnstanceQ;
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:// locaihost:
3306/Library”,”root’,”reeta”);
// Create SQL statement and execute query. stmt con.create

rs = Stmt.executeQuery(query)
}
if(rs.next()){
String MName = rs.getstring(”memb_name”)
String mAdd = rs.getstring(“memb_ add”);
String MPh1 = rs.getstring(“memb_ phone”);
String MDate = rs.getstring(“mdate”);
String MEDate = rs.getstring(”medate”)
String MFee = rs.getString(”mfee”),
String NiStatus = rs.getString(“ status’);
String Missue rs.getString(’mem_issue”);
// Displaying the contents in respective text boxes.
txtM No. setText(Mno);
txtMName. setText(MName);
txtMAdd .setlext(MAdd);
txtNl Ph .setText(MPhl);
txtMDate.setText(Mdate);
txtM Pee.setText(M Fee);
txtM Status.setText(Mstatus);
txtM Status .setEditable(false);
} else {
JOptionPane.showMessageDialog(null, “Record does not found in Member table”);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}

Form load procedure:


private void formW awt event WindowEvent evt) {
txtM No. setEditable (f alse);
txtMStatus . setEditable(false);
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListModel) jList1.getModel
// Method to add elements into jListl control
dModel.clear();
try {
Class.forName(”com.mysql.jdbc.Driver’);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:// locaihost:
3306/Library”,”root’,”reeta”);

rs = stmt.executeQuery(SQL);
while (rs.next()){
Strirg Mno = rs.getString(”rnemb_no”);
Stnrg MName rs.getString(’rnemb _name’);
// To make the Member no. as 4 digit because we will extract 4 digit from list value
//in mouse click event.
if (Mno.length() <4)
{
int x = Mno.length();
int nl = 4 – x ;
while (nl > 0) {
Mrio = Mi o + “”;
nl- -;
}
}

dModeladdElement(Mno +”-“+ MName);


}
jListl .setModel(dModel);
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e. printStackTrace();
}
}
Member Deletion (MembDelUljava)

SOURCE Code: MembDelUIjava

Used Class/Packages
import java.sql*;
mport javax.swing.JOptionPane;
import javax.swing.DefaultListModel;

Global Variables

Statement stmt = null;


ResultSet rs = null;
String SQL = SELECT * FROM Member;

ActionEvent Procedures :

private void jListlMouseClicked(java.awt.event.MouseEvent evt) {


// getSelectedValue() method extracts the current cursor location value
String MembNo = (String) jListl .getSelectedValue();
// Extract the first 4 characters as Member No into a variabie
String Mno =MembNo.trim().substring(O, 3);
String query = SELECT * FROM Member WHERE memb_no = “+ (Mno) + “;“;

try {
Class.forName(”com.mysql.jdbc.Driver’);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:// locaihost:
3306/Library”,”root’,”reeta”);
// Create SQL statement and execute query.
stmt = con.createstatement();
r stmt.executeQuery(query);
if (rs.nextQ) {
String MName = rs.getString(”memb_name”)
String mAdd = rs.getstring(“memb_ add”);
String MPh1 = rs.getstring(“memb_ phone”);
String MDate = rs.getstring(“mdate”);
String MEDate = rs.getstring(”medate”)
String MFee = rs.getString(”mfee”),
String NiStatus = rs.getString(“ status’);
String Missue rs.getString(’mem_issue”);
// Displaying the contents in respective text boxes.
txtMNo.setText(Mno);
txtMName.setText(MName);
txtMAdd . setText(MAdd);
txtMPh.setText(MPh 1);
txtMDate.setText(MDate);
txtM Fee .setText( MFee);
txtMStatus,setText( Mstatus);
txtMStatus.setEditable(false);
} else {
JOptionPane.showMessageDialog(null, “Record does not found in Member
table”);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage();
}
}

Exit ActionEvent Procedure:


private void cmdExitlActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
//new MainUI().setVisible(true);
}
Delete ActionEvent Procedure
private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName(”com.mysql.jdbc.Driver’);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:// locaihost:
3306/Library”,”root’,”reeta”);
stmt = con.createstatement();
rs = stmt.executeQuery(SQL);
int Mno = Integer.parseInt(txtMNo.getText() .trim());
// Steps to confirm deletion
int opt = JOptionPane.showConfirrnDialog(null, “Are you sure to delete this record ?“);
if (opt JOptionPane.YES_ OPTION) {
try {
char stb =’ N’; // Member table
String strSQL = “Update Member set mem_status = “+(stb)+
“wher memb no = ‘ + (Mno);
int rowsEff ected = stmt.executeUpdate(strSQL);
if (rowsEffe ted = = 0)
JOptionPane.showMessageDialog(this, “Record does not exists”);
I
else {
JOptionPane.showMessageDiaiog(this,”Record Deleted);
// Text boxes cleared
txtMNo.setText(“”);
txtMName.setText(“”);
txtMAdd . setText(“”);
txtMPh.setText(“”);
txtMDate.setText(“”);
txtM Fee .setText( “”);
txtMStatus,setText( “’);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, “Unable to delete’);
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
Form load procedure
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtM No, setEditable ( false);
txtMName.setEditable( false);
txtMAdd .setEditable(false);
txtMPh .setEditab (false);
txtMDate.setEditable(false);
txtMFee.setEditable(false);
txtMStatus.setEditable(false);
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListMode dModel = (DefaultListModel) jListl.getMode
// Method to add elements into jListl control
dModel.clear();
try {
Class.forName(”com.mysql.jdbc.Driver’);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:// locaihost:
3306/Library”,”root’,”reeta”);
stmt = con.createstatement();
rs = stmt.executeQuery(SQL);
while(rs.next()){
String Mno = rs.getString(“memb_no”);
String MName = rs.getString(“memb_name”);
// To make the Member no. as ‘ because we will extract 4 digit from list value
// in mouse click event.
if (Mno.Iength() < 4)
{
int x = Mno.length();
int nl = 4 - x;
while (nl > O){
Mno = Mno +””;
nl--;
}
}
dModel.addElement(Mno + “- “ + MName);
}
jListl .setNlodel(dModel);
} catch (Exception e) (
JOption Pane. showMessageDialog(this, e.getMessage ());
e. printStackTrace();
}
}
Member Navigation (MembNavUijava)

Source Code: MembNavUijava

Used Class/Packages
import java.sql.*;
import javax.swing.JOptionPane;

Global Variables with a method

Statement stmt null;


ResultSet rs = null;
String SQL = ‘SELECT * FROM Member”;
public void disable_textfields() {
txtMNo.setEditable(false);
txtMName.setEditable(false);
txtMAdd.setEditable(false);
txtMPh.setEditable(false);
txtMDate,setEditable(false);
txtMFee. setEditable(false);
txtMStatus.setEditable(false);
txtMlssue.setEditable(false);
}

Previous ActionEvent Procdures


private void cmdPrevActionPerformed( java.awt.event.ActionEvent evt) {
try {
Class.forName(”com.mysql.jdbc.Driver’);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:// locaihost:
3306/Library”,”root’,”reeta”);
if (rs.previous()) {
String Mno = rsgetString(”rnemb_no”);
String MName = rs.getString(”memb_name ‘);
String MAdd = rs.getString(“ memb_add”);
String MPh1 = rs.getString(”memb phone”);
String MDate = rs.getString(”mdate “);
String MEDate = rs.getString( “mdate”);
String MFee = rs.getString(“mfee”);
String MStatus = rs.getString( status);
String Mlssue = rs.getString(”memb_issue);
// Displaying the contents in respective text boxes.
txtM No. setText( M no)
txtM Na me. setText(MName)
txtMAdd . setText( MAdd);
txtMPh.setText(MPh 1);
txtMDate.setText( MDate);
txtMFee.setText(MFee);
txtMStatus .setText(MStatus);
txtMlssue.setText(Mlssue);
cmdFirst.setEnabied(true);
cmdNext.setEnabled(true);
cmdPrev. setEnabled (true),
cmdLast.setEnabled (true)
}else {
cmdPrev.setEnabled(false);
JOptionPane.showMessageDialog(this,”You are at first position”, ‘Student,O);
} catch (Exception e) {
JOptionPane.showMessageDiloge(this,e.getMessage());
}
}
Last ActionEvent procedure:

private void cmdLastActionPertormed(java,awt.event.ActionEvent evt) {


try{
Class.forName(”com.mysql.jdbc.Driver’);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:// locaihost:
3306/Library”,”root’,”reeta”);
if (rs.last()) {
String Mno = rs.getString(”memb no’);
String MName = rs.getString(memb_name”);
String MAdd = rs.getString(’memb_add”);
String MPh1 = rs.getString(memb phone);
String MDate = rs.getString(’mdate”);
String MEDate = rs.getString(“medate”)
String MFee = rs.getString(“mfee”);
MStatus = rs.getString(”mem_status”);
String Mlssue = rs.getString(”mem_issue”);
// Displaying the contents in respective text boxes.
txtM No. setText( M no)
txtM Na me. setText(MName)
txtMAdd . setText( MAdd);
txtMPh.setText(MPh 1);
txtMDate.setText( MDate);
txtMFee.setText(MFee);
txtMStatus .setText(MStatus);
txtMlssue.setText(Mlssue);
cmdFirst.setEnabied(true);
cmdNext.setEnabled(false);
cmdPrev. setEnabled (true),
cmdLast.setEnabled (false)

} else {
JOptionPane.showMessageDialog(this, You are already at last record”, “Student”,O);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}

Next ActionEvent Procedures


private void cmdNextActionPerformed(java.awt.eventActionEvent evt) {
}
try{
Class.forName(”com.mysql.jdbc.Driver’);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:// locaihost:
3306/Library”,”root’,”reeta”);
if (rs.next()) {
String Mno = rs.getString(”memb no’);
String MName = rs.getString(memb_name”);
String MAdd = rs.getString(’memb_add”);
String MPh1 = rs.getString(memb phone);
String MDate = rs.getString(’mdate”);
String MEDate = rs.getString(“medate”)
String MFee = rs.getString(“mfee”);
MStatus = rs.getString(”mem_status”);
String Mlssue = rs.getString(”mem_issue”);
//Displaying the contents in respective text boxes.
txtM No. setText( M no)
txtM Na me. setText(MName)
txtMAdd . setText( MAdd);
txtMPh.setText(MPh 1);
txtMDate.setText( MDate);
txtMFee.setText(MFee);
txtMStatus .setText(MStatus);
txtMlssue.setText(Mlssue);

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

Exit ActionEvent Procedure

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


this. setVisible(false);
}

First ActionEvent Procedures


private void cmdFirstActioflperforrned (java.awt.event.ActionEvent.evt){
try {
Class.forName(”com.mysql.jdbc.Driver’);
Connection con = (Connection)
DriverManager.getConnection(’jdbc: mysql:// locaihost:
3306/Library”,”root’,”reeta”);
if (rs.next()) {
String Mno = rs.getString(”memb no’);
String MName = rs.getString(memb_name”);
String MAdd = rs.getString(’memb_add”);
String MPh1 = rs.getString(memb phone);
String MDate = rs.getString(’mdate”);
String MEDate = rs.getString(“medate”)
String MFee = rs.getString(“mfee”);
MStatus = rs.getString(”mem_status”);
String Mlssue = rs.getString(”mem_issue”);
//Displaying the contents in respective text boxes.
txtM No. setText( M no)
txtM Na me. setText(MName)
txtMAdd . setText( MAdd);
txtMPh.setText(MPh 1);
txtMDate.setText( MDate);
txtMFee.setText(MFee);
txtMStatus .setText(MStatus);
txtMlssue.setText(Mlssue);

cmdFirst.setEnabled(false);
cmdNext.setEnabled(true);
cmdPrev.setEnabled( false);
cmdLast.setEnabled(true);

} else {
cmd First. setEna bled (false)
cmd Next. setE na bled (false)
crnd prev.setEflabled(false)
cmd Last.setEna bled (false)
JOptionPane.showMeSSageDialOg(this, Rhere is no record in table’, “Student’,O);
}
} catch (Exception e) {
JOptionpane.showMessageDialog(this,e.getMessageO);
}
}

Form load procedure


private void formWindowGainedFocus(java.awt.eventWindowEvent. evt) {
disable_textfields();
try {
Class ,fo rNa me( “ corn. mysql.jdbc. Driver”)
Connection con = (Connection)
DriverManager.get Connection (”jdbc: mysql ://localhost:
3306/Library’,root”,’reeta’)
stmt = con.createStatement();
rs = stmt.executeQuery(SQL)
String Mno = rs.getString(”memb no’);
String MName = rs.getString(memb_name”);
String MAdd = rs.getString(’memb_add”);
String MPh1 = rs.getString(memb phone);
String MDate = rs.getString(’mdate”);
String MEDate = rs.getString(“medate”)
String MFee = rs.getString(“mfee”);
MStatus = rs.getString(”mem_status”);
String Mlssue = rs.getString(”mem_issue”);
//Displaying the contents in respective text boxes.
txtM No. setText( M no)
txtM Na me. setText(MName)
txtMAdd . setText( MAdd);
txtMPh.setText(MPh 1);
txtMDate.setText( MDate);
txtMFee.setText(MFee);
txtMStatus .setText(MStatus);
txtMlssue.setText(Mlssue);

cmdFirst.setEnabled(false);
cmdNext.setEnabled(true);
cmdPrev.setEnabled( false);
cmdLast.setEnabled(true);

} else {
cmd First. setEna bled (false)
cmd Next. setE na bled (false)
crnd prev.setEflabled(false)
cmd Last.setEna bled (false)
JOptionPane.showMeSSageDialOg(this, Rhere is no record in table’, “Student’,O);

}
} catch (Exception e) {
JOPtionPane.showMessageDialog(this, e.getMessage());
}
}
Available Book List (ABListUl.java)

Source Code: ABListUl.java

Used Class/Packages
import javax.swing.table.*;
import java.sqi.*;
import javax.swing.JOptionPane;

Form load procedure


private void formWindowGainedFocus(java.awt.eventWindowEvent. evt) {
// Before writting the followng line, you should import the line:
//import javax.swing.table.*; at the top of your application
DefaultTableModel model = (DefaultTableModel) jTablel .getModel();
// Clear the existing table
int rows = model.getRowCount();
if (rows > 0) {
for (mt = 0; i < rows; i++) {
model. remove Row(0);
}
}
}
// SQL Query
char st = ‘Y’; // Lib table
String query = “SELECT * FROM Lib WHERE status = “ + St + “;“;
try{
// Connect to MySQL database
Class.forName(”com.mysql.jdbc.Driver”). newInstance();
Connection con = (Connection) DriverManager.getConnection(”jdbc: mysql //
localhost: 3306/Library”,”root”,”reeta”);
// Create SQL statement and execute query.
Statement stmt = con createStatement();
ResultSet rs = stmt.executeQuery(query);
//Iterate through the result and display on screen
while (rs.next()) {
String Acno = rs.getString(”acc_no”);
String bTitle rs.getString( “btitle”);
String Auth 1 rs.getString(”author1”);
String Price = rs.getString(”price”);
String edition rs.getString(”edition”);
//System,out.println(Acno + “I” + bTitle + “j” + Authi + “ + Price + “i” + edition);
model.addRow(new Object {Acno, bTitle, Authi, Price, edition});
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}

Exit ActionEvent Procedure:


private void cmdExitActionPerformed(java . awt.event.Action Event evt) {
this.setVisibie(false);
}
private void cmdlssueActionPerformed(javaawt.event.ActionEvent evt) {
MyDialog .setVisible(true);
}
private void cmdBackActionPerformed(java awt.event.ActionEvent evt) {
MyDialog.dispose();
}
Dialog window load procedure :
Private void MyDialogWindow ?GainedFocus(java.awt.event.WindowEvent evt){
DefaultTaleModel Dmodel = (DefaultTableModel) jTable2.getModel();
//Clear the existing table
Int rows = Dmodel.getRowCount();
If (row>0){
for(int i= 0; i<=rows;i++){
Dmodel.removeRow(0);
}
}
//SQL Query
char st = ‘N; // Lib table
String query =” SELECT”* FROM Lib WHERE status = “ + St +”;”;
try{
// Connect to MySQL database
Class.forName(”com.mysql.jdbc.Driver”). newInstance();
Connection con = (Connection) DriverManager.getConnection(”jdbc: mysql //
localhost: 3306/Library”,”root”,”reeta”);
// Create SQL statement and execute query.
Statement stmt = con createStatement();
ResultSet rs = stmt.executeQuery(query);
//Iterate through the result and display on screen
while (rs.next()) {
String Acno = rs.getString(”acc_no”);
String bTitle rs.getString( “btitle”);
String Auth 1 rs.getString(”author1”);
String Price = rs.getString(”price”);
String edition rs.getString(”edition”);
//System,out.println(Acno + “/” + bTitle + “/” + Authi + “ + Price + “/” + edition);
model.addRow(new Object {Acno, bTitle, Authi, Price, edition});
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
Issued Book List (IBLIstUI.java)

Source Code: IBListUI.java

Used Class/Packages
import javax.swing.table.*;
import java.sql.*;
import javax.swing.JOptionPane;

Exit_ ActionEvent Procedure:

private void cmdExitActionPerformed(java.awt.event.i evt) {


this.setVisible(false);
}
Form load procedure
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
// Before writting the followng line, you should import the line:
// import Javax.swing.table.*; at the top of your application
DefaultTableModel model = (DefaultTableModel) jTablel.getModel();
// Clear the existing table
int rows = model.getRowCount ();
if (rows > 0) {
for (mt = 0; < rows; i++) {
model. removeRow( 0);
}
}
// SQL Query
char st = N; // Lib table
String query = “SELECT * FROM Lib WHERE status = “ + St + “;“;
try {
// Connect to MySQL database
Class.forName(com.mysql.jdbc. Driver”).newlnstance();
Connection con = (Connection) DriverManager.getConnection(“jdbc:mysql://
localhost: 3306/Library”,root”,”reeta”);
// Create SQL statement and execute query.
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
// Iterate through the result and display on screen
while (rs.nexto) {
String Acno = rs.getString(”acc_no”);
String bTitle rs.getString( “btitle”);
String Auth 1 rs.getString(”author1”);
String Price = rs.getString(”price”);
String edition rs.getString(”edition”);
//System,out.println(Acno + “/” + bTitle + “/” + Authi + “ + Price + “/” + edition);
model.addRow(new Object {Acno, bTitle, Authi, Price, edition});
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
Member List IMListULjava)

Source Code: ML1stUI.java


Used Class/Packages
import javax.swing.table.*;
import java.sql.*;
import javax.swing. JOptionPane;
Exit ActionEvent Procedure
private void cmdExitActionPerformed(java,awt evt) {
this.setVisible(false);
}
Form load procedure :
private void formWindowGainedFocus(java.awt evt) {
// Before writting the followng line, you should import the line:
// import javax.swing.table.*; at the top of your application
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
// Clear the existing table
int rows = model.getRowCount();
if (rows > 0) {
for (int i 0; i < rows; i++) {
model. rernoveRow(0);
}
}
// SQL Query
String query = ‘SELECT * FROM Member’;
try {
// Connect to MySQL database
Class.forName(com.mysql.jdbc. Driver”).newlnstance();
Connection con = (Connection) DriverManager.getConnection(“jdbc:mysql://
localhost: 3306/Library”,root”,”reeta”);
// Create SQL statement and execute query.
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
// Iterate through the result and display on screen
while (rs.next()) {
String MNo= rs.getString(“memb_no”);
String MName = rs.getString(“memb_ name”);
String MAad = rs.getString(”memb_add”);
String MPhI = rsgetstring(“memb_phone’);
String MDate = rs.getString(“ mdate”);
//Systern.out.println(Mno + “I’ + MName + “I” + M.Add + “I” + MPh1 + ““I” +
MDate);
Model.addRow(new Object {Mno, M name, MAdd, MPhI, MDate});
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
Conclusion

After the successful complesion of this project I have gained complete


knowledge of java and MySQL , while doing this project I have used all
the knowledge and skill I have acquired in this past years . I would like
to thank my teacher Mrs. Shabana Parveen who helped me through out
the session by empowering my thoughts with her precious advice and
guience

NIRUPAMA
Class-Xii
Roll No _______
Students Data

Name : NIRUPAMA
Class : XII
Div : “D”
Roll No :
School : Kairali School
Sector-II,
Dhurwa,Ranchi
Jharkhand

You might also like