library report

138
Project Report On LIBRARY MANAGEMENT SYSTEM Using Core java PROGRAMMING 2008- 2012 PDM COLLEGE OF ENGINEERING & TECHNOLOGY,BAHADURGARH

Upload: preeti-lochab

Post on 15-Oct-2014

46 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Library Report

Project ReportOn

LIBRARY MANAGEMENT SYSTEM

Using Core java PROGRAMMING

2008-2012

PDM COLLEGE OF ENGINEERING & TECHNOLOGY,BAHADURGARH

Page 2: Library Report

Submitted to:Mr. Aman Dureja

Submitted by: Preeti lochab 8006 c.s.e-1 5th semester

TABLE OF CONTENTS

Page 3: Library Report

1. Acknowledgement2. Certificates3. Introduction4. Demerits of file processing system5. Why choose this project6. Platform7. Introduction to java language8. Introduction to project9. coding of the project10.outputs or snapshots11.bibiliography

Page 4: Library Report

ACKNOWLEDGEMENT

I would like to express my sincere thanks and deep gratitude to all those people who extended their

wholehearted co-operation and have helped me in completing this project successfully.

First of all, I would like to thank my Project Guide Mr. AMAN JUNEJA, for providing excellent

opportunity to do a project on LIBRARY MANAGEMENT and providing me with all the essential

elements required for the completion and enhancement of this project. Our faculty made us endures such

times with their unfailing humors and warm wishes. The effort could not be successfully completed

without timely guidance and suggestions by the staff members of PDM College of Engineering.

Secondly, I would also like to thank the staff members of NIIT,rajendra place who had also whole

heartedly helped me in completion of the project. During the summer vacations ,I learned core java from

NIIT,due to which I am able to complete this project.

Thirdly,I would like to thank my friends and my family for their co-operation towards my

project.Again , I would like to thank everyone who has helped me in completion of the project.

(PREETI LOCHAB)

Page 5: Library Report

INTRODUCTION

Overview

Gecap Softwares offer end-to-end IT consulting services using the best practices in the

industry. Our solutions include Training, Software Development Services, Consulting &

IT Outsourcing.

Training

Our trainers are from great network of best alumni of IIT’s IIM’s, Stanford, Harvard,

MIT and LSE, having rich experience of delivering crucial training in international level.

Outsourcing

Gecap is a global staffing solutions provider to IT companies. Its staffing solutions

division called the Skilled Resource Center – SRC, excels in providing manpower

support for permanent staffing and contract hiring at few of the largest corporations in

India.

Development

The Software Service includes

Application Development

Software Development

Business Analytics

Web Designing

Supply Chain Management

Network Infrastructure

IT Consulting

Consulting in       

Page 6: Library Report

Gecap Softwares Known For its Excellence in Software Education. We arrange

workshop and career oriented courses like; Java: Training in Java, Online training in Java

, J2EE Certification, J2EE Application Server, J2ME Dictionary, Sun Certification

training, Struts Caching, Struts2, Hibernate, Spring Training , EJB Training, EJB

Certification,.NET: .NET Training Classes, .NET framework, Asp.NET Training Course,

Asp.NET Ajax, C# , MCTS Certification, Embedded: Embedded Systems, Telecom India

2008, Telecom India News, WinCE5.0, Linux Device Driver, Linux Device Driver

Development, ARM Training, Brew 2008, Brew Tree, GSM India, GSM Technologies,

VC++, VC++ 2008, Mainframes, Cobol, Oracle: Training And Certification, Oracle 9i,

Oracle 10g Certification Requirements, Sql Reference, Software Quality Testing: SQT

Training, Testing Web Applications, Automaton Training along with Testing Techniques,

SOA: Service Oriented Architecture Certification, SOA Certified, SOA Consultancy, etc.

Application

Our experienced system analysts and developers work on your custom project from its

conceptualization through its completion. It's easy to offer deployable systems and install

them, but we will remain with you to insure that your technical personnel and other

employees can successfully use the application. We also offer customized

maintenance/support contracts to meet most any need.

Highly experienced & qualified Technical and software professionals back services.

Apart from the experience in Gecap Software, team members have several years of

Page 7: Library Report

expertise in developing customized, fully integrated systems.

Apart from highly skilled Software Architects, Software Engineers and web developers,

our assemblage features Visualizes, Web Developers, Quality Assurance Analysts,

Document Writers, Network Engineers, Management, Finance & Administrative Experts,

Business Development Managers, and others. We combine all these skills with our

management skills to provide our clients with excellent end results. In all, we have a team

exposed to every possible software service and platform knowledge.

Portal Solutions:

Ecommerce Application Development

Shopping Cart Development

Payment Gateway Integration

B2B, B2C, C2C Websites

Dynamic News System

Portal Site Design

 

Web Application Development

Chat Server

Page 8: Library Report

Discussion Forum

Jobs Module

Dating/Matrimonial

Weather Solutions

Classifieds

Banner Solution

Affiliate Management System

Custom Programming

Intranet Solutions

Ecommerce Application Development

Ecommerce Website Design

DEMERITS OF FILE PROCESSING SYSTEM-1. Program-Data Dependence. File descriptions are stored within each application program that accesses a given file.

Page 9: Library Report

2. Duplication of Data. Applications are developed independently in file processing systems leading to unplanned duplicate files. Duplication is wasteful as it requires additional storage space and changes in one file must be made manually in all files. This also results in loss of data integrity. It is also possible that the same data item may have different names in different files, or the same name may be used for different data items in different files.

3. Limited data sharing. Each application has its own private files with little opportunity to share data outside their own applications. A requested report may require data from several incompatible files in separate systems.

4. Lengthy Development Times. There is little opportunity to leverage previous development efforts. Each new application requires the developer to start from scratch by designing new file formats and descriptions

5. Excessive Program Maintenance. The preceding factors create a heavy program maintenance load.

6. Integrity Problem. The problem of integrity is the problem of ensuring that the data in the database is accentuate.

7. Inconsistance data

8. Security

Why choose the THIS PROJECT?THIS PROJECT has integrated the best features.THIS PROJECT has been designed to provide the following benefits:

Easy RECORD MAINTAINCE

Advanced FACILITES AVALAIBLE

Advanced moderation features

Page 10: Library Report

Integrable

Customizable

Secure

Powerful

PLATFORM

The project is developed on the system having following configuration:

Operating System: Windows XP Professional

Processor: Intel(R) CORE(TM) 2 DU

Hard Disk: 80GB

Page 11: Library Report

RAM: 292MB

JAVA

Java is an object oriented language, multithreaded programming language

developed by Sun Microsystems in 1991.it is designed to be small, simple and portable

across different platforms as well as operating systems.

The popularity of Java is due to its unique technology that is designed on the basis

of three key elements. They are the usage of applets, powerful programming language

constructs and a rich set of significant object classes.

Page 12: Library Report

When a program is compiled, it is translated into machine code or processor

instructions that are specific to the processor. In the Java development environment there

are two parts: a Java compiler and a Java interpreter. The compiler generates the byte

code (a set of instructions that resemble machine code but are not specific to any

processor) instead of machine code and the interpreter executes the Java program.

The disadvantage of using byte code is the execution speed. Since system specific

programs run directly on the hardware, they are faster than the Java byte codes that is

processed by the interpreter.. In order to write a Java program, an editor, a Java

compiler and a Java Runtime Environment are needed.

The editor can be a Notepad, Wordpad, MS-DOS editor etc. the easiest way to get

a Java Compiler and Runtime Environment is to download Sun’s Java Development

Kit. This provides system input and output capabilities and other utility functions in

addition to classes that support networking, common Internet protocols and user interface

toolkit functions

Java virtual machine

The heart of the Java Platform is the concept of a "virtual machine" that executes Java

byte code programs. This byte code is the same no matter what hardware or operating

system the program is running under. There is a JIT compiler within the Java Virtual

Machine, or JVM. The JIT compiler translates the Java byte code into native processor

instructions at run-time and caches the native code in memory during execution.

Page 13: Library Report

The use of byte code as an intermediate language permits Java programs to run on any

platform that has a virtual machine available. The use of a JIT compiler means that Java

applications, after a short delay during loading and once they have "warmed up" by being

all or mostly JIT-compiled, tend to run about as fast as native programs. Since JRE

version 1.2, Sun's JVM implementation has included a just-in-time compiler instead of an

interpreter.

Although Java programs are platform independent, the code of the Java Virtual Machine

(JVM) that executes these programs is not: Every supported operating platform has its

own JVM.

Page 14: Library Report

FEATURES OF JAVA

SIMPLE:

JAVA was designed to be easy for the professional programmer to learn and use

effectively. If you have some programming experience, you will not find java hard to

master. If you already understand the basic concept of object–oriented programming,

learning java will be even easier.

OBJECT-ORIENTED:

Although influenced by its predecessors, java was not designed to be source-code

compatible with any other language. This allowed the java team the freedom to design

with a blank state.

ROBUST:

The multiplatform environment of the Web places extraordinary demands on a program,

because the program must execute reliably in a variety of systems. The ability to create

robust programs was given a high priority in the design of java.

To better understand how Java is robust, consider two of the main reasons for program

failure: memory management mistakes and mishandled exceptional conditions (that is run

time errors) Java virtually eliminates these problems by managing memory allocation and

deallocation for you.

MULTITHREADED:

Java was designed to meet the real-world requirement of creating interactive,networked

programs.To accomplish this Java supports multithreaded programming, which allows

Page 15: Library Report

you write programs that do many things simultaneously. The Java run-time system comes

with an elegant yet sophisticated solution for multiprocessor synchronization that enables

you to construct smoothly running interactive systems. Java easy to use approach to

multithreading allows you to think about the specific behavior of your program, not the

multitasking subsystem.

ARCHITECTURE-NEUTRAL:

A central issue for the Java designer was that of code longevity and portability. One OF

THE MAIN PROBLEMS FACING PROGRAMMERS IS THAT NO GUARANTEE

EXITS THAT IF YOU WRITE PROGRAM TODAY. Operating system upgrades

processor upgrades and changes in core system resources can all combine to make a

program malfunction.

INTERPRETED AND HIGH PERFORMANCE:

JAVA ENABLES THE CREATION OF CROSS-PLATFORM PROGRAMS by

compiling into an intermediate representation called Java byte code. This code can be

interpreted on any system that provides a Java byte code. This code can be interpreted on

any system that provides a Java Virtual Machine

DISTRIBUTED:

JAVA is designed for the distributed environment of the Internet because it handles

TCP/IP protocol. In fact accessing a resource using URL is not much different from

accessing a file .The original version of Java included features for intra address space

messaging. This allowed objects on two different computers to execute procedures

remotely.

DYNAMIC:

Page 16: Library Report

JAVA programs carry with them substantial amounts of run-time type information that is

used to verify and resolve access to objects at run time. This is crucial to robustness of

the applet environment in which small fragments of byte code may be dynamically

updated on a running system.

OBJECT ---ORIENTED PROGRAMMING APPROACH:

OBJECT-ORIENTED programming is at core of java .In fact, all java programs are

object-oriented –this isn’t an option the way that it is in C++, for example, OOP so

integral to java that you must understand the basic principles before you can even write

even simple Java programs.

SECURE:

Threatening of viruses and system hackers also exists. To overcome all these fears, Java

has safety and security as its key design principle. Using Java compatible Web Browser,

anyone can safely download Java applets without the fear of viral infection or malicious

intent. Java achieves this protection by confining a Java program to the Java execution

environment and by making it inaccessible to other parts of the computer.

Page 17: Library Report

ABSTRACT WINDOW TOOL KIT(AWT)

The Abstract Window Toolkit (AWT) is Java's original platform-independent

windowing, graphics, and user-interface widget toolkit. The AWT is now part of the Java

Foundation Classes (JFC) — the standard API for providing a graphical user interface

(GUI) for a Java program.

Windows form with some AWT examples

Page 18: Library Report

The AWT provides, among other things:

A basic set of GUI widgets such as buttons, text boxes, and menus

The core of the GUI event subsystem

The interface between the native windowing system and the Java application

Several layout managers

A java.awt.datatransfer package for use with the Clipboard and Drag

and Drop

The interface to input devices such as mice and keyboards

The AWT Native Interface, which enables rendering libraries compiled to native

code to draw directly to an AWT Canvas object drawing surface.

Access to the system tray on supporting systems

The ability to launch some desktop applications such as web browsers and email

clients from a Java application

SWING

Page 19: Library Report

Swing is a set of classes that provides more powerful and flexible components than are

possible with the AWT. In addition to the familiar components, such as buttons, check

boxes, and labels, Swing supplies several exciting additions, including tabbed panes,

scroll panes, trees, and tables. Even familiar components such as buttons have more

capabilities in Swing. For example, a button may have both an image and a text string

associated with it. Also, the image can be changed as the state of the button changes.

Unlike AWT components, Swing components are not implemented by platform-specific

code. Instead, they are written entirely in Java and, therefore, are platform-independent.

The term lightweight is used to describe such elements.

Page 20: Library Report

EVENT HANDLING

Event Handling is at the core of successful applet programming. Most events to which

your applet will respond are generated by the user. These events are passed to your applet

in a variety of ways, with the specific method depending upon the actual event. There are

several types of events. The most commonly handled events are those generated by the

mouse, the keyboard, and various controls, such as a push button. Events are supported

by the java.awt.event package.

The Delegation Event Model:

The modern approach to handling events is based on the delegation event model, which

defines standard and consistent mechanisms to generate and process events. Its concept is

quite simple: a source generates an event and sends it to one or more listeners. In this

scheme, the listener simply waits until it receives an event. Once received, the listener

processes the event and then returns. The advantage of this design is that the application

logic that processes events is cleanly separated from the user interface logic that

generates those events. A user interface element is able to “delegate” the processing of an

event to a separate piece of code.

In the delegation event model, listeners must register with a source in order to receive an

event notification. This provides an important benefit: notifications are sent only to

listeners that want to receive them. This is a more efficient way to handle events than the

design used by the old Java 1.0 approach. Previously, an event was propagated up the

containment hierarchy until it was handled by a component. This required components to

receive events that they did not process, and it wasted valuable time. The delegation

event model eliminates this overhead.

Page 21: Library Report

Events:

In the delegation model, an event is an object that describes a state change in a source. It

can be generated as a consequence of a person interacting with the elements in a

graphical user interface. Some of the activities that cause events to be generated are

pressing a button, entering a character via the keyboard, selecting an item in a list, and

clicking the mouse. Many other user operations could also be cited as examples.

Events may also occur that are not directly caused by interactions with a user interface.

For example, an event may be generated when a timer expires, a counter exceeds a value,

software or hardware failure occurs, or an operation is completed. You are free to define

events that are appropriate for your application.

Event Sources:

A source is an object that generates an event. This occurs when the internal state of that

object changes in some way. Sources may generate more than one type of event. A

source must register listeners in order for the listeners to receive notifications about a

specific type of event. Each type of event has its own registration method. Here is the

general form:

public void addTypeListener(TypeListener el)

Here, Type is the name of the event and el is a reference to the event listener. For

example, the method that registers a keyboard event listener is called addKeyListener( ).

The method that registers a mouse motion listener is called addMouseMotionListener().

When an event occurs, all registered listeners are notified and receive a copy of the event

object. This is known as multicasting the event. In all cases, notifications are sent only to

listeners that register to receive them.

Event Listeners:

Page 22: Library Report

A listener is an object that is notified when an event occurs. It has two major

requirements. First, it must have been registered with one or more sources to receive

notifications about specific types of events. Second, it must implement methods to

receive and process these notifications. The methods that receive and process events are

defined in a set of interfaces found in java.awt.event. For example, the

MouseMotionListener interface defines two methods to receive notifications when the

mouse is dragged or moved. Any object may receive and process one or both of these

events if it provides an implementation of this interface.

Event Classes:

The classes that represent events are at the core of Java’s event handling mechanism.

Thus, we begin our study of event handling with a tour of the event classes. As you will

see, they provide a consistent, easy-to-use means of encapsulating events. At the root of

the Java event class hierarchy is Event Object, which is in java.util. It is the superclass

for all events. The class AWTEvent, defined within the java.awt package, is a subclass

of EventObject. It is the superclass (either directly or indirectly) of all AWT-based

events used by the delegation event model. Its getID( ) method can be used to determine

the type of the event.

To summarize:

EventObject is a superclass of all events.

AWTEvent is a superclass of all AWT events that are handled by the delegation

event model.

Compilation in JAVA

Page 23: Library Report

Text Editor :- Text Editor is that in which we write the text . That is, in notepad

we write the text.

Source Code - The text converted into source code. The extension of source code

is filename.java. That means my filename is Logon. So the extension of this is

Logon .java.

Java Compiler - Then source code goes to the java compiler. It converts source

code into bytecode.

Byte codes - These are the machine instructions. Its extension is filename.class.

Java Interpreter - Its execute the program. It provides hardware specifiers to

compile through java software.

Operating system - Then the program display on operating system.

HOW TO RUN AND COMPILE JAVA LIBRARY MANAGEMENT SYSTEM

Page 24: Library Report

Microsoft Windows XP [Version 5.1.2600]

(C) Copyright 1985-2001 Microsoft Corp.

F:\LibraryMgt>javac *.java

F:\LibraryMgt>java Logon

preeti

Page 25: Library Report

import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;

public class Logon extends JFrame implements ActionListener {

public Dimension d = Toolkit.getDefaultToolkit().getScreenSize();private int fl=1;private JPanel pLog = new JPanel();

//private JPanel pLog1=new JPanel(); private JLabel lbUser, lbPass;private JTextField txtUser;private JPasswordField txtPass;private JButton btnOk, btnCancel;private JRadioButton rad,rcle,rmem;private Connection con;public String user;FrmSplash FormSplash = new FrmSplash();Thread ThFormSplash = new Thread(FormSplash);

Color c1=new Color(240,98,166); Color c2=new Color(243,112,97);

public Logon () {

super ("Library Management System.");loadSplashScreen();FormSplash.dispose();setIconImage (getToolkit().getImage ("Images/Home.gif"));setSize (275, 300);setResizable (false);

Page 26: Library Report

addWindowListener (new WindowAdapter () {public void windowClosing (WindowEvent we) {

setVisible (false);dispose(); System.exit (0);

}});

//Setting the Logon Form Position on User's Screen.

setLocation (d.width / 2 - getWidth() / 2, d.height / 2 - getHeight() / 2);

//Setting the Layout of Panel.

pLog.setLayout (null);

//Setting the Form's Radio Button'srad=new JRadioButton("ADMIN");rad.setBounds(80,140,100,25);

rad.setBackground(c2);rad.addActionListener(this);

rcle=new JRadioButton("CLERK");rcle.setBounds(80,170,100,25);

rcle.setBackground(c2);rcle.addActionListener(this);

rmem=new JRadioButton("MEMBER");rmem.setBounds(80,200,100,25);

rmem.setBackground(c2); rmem.addActionListener(this);rad.setSelected(true);

ButtonGroup bg=new ButtonGroup();bg.add(rad);bg.add(rcle);bg.add(rmem);

Page 27: Library Report

//Setting the Form's Labels.

lbUser = new JLabel ("Username:");lbUser.setForeground (Color.black);lbUser.setBounds (20, 15, 75, 25);

lbPass = new JLabel ("Password:");lbPass.setForeground (Color.BLACK);

lbPass.setBounds (20, 50, 75, 25);

//Setting the Form's TextField & PasswordField.

txtUser = new JTextField ();txtUser.setBounds (100, 15, 150, 25);txtPass = new JPasswordField ();txtPass.setBounds (100, 50, 150, 25);

//Setting the Form's Buttons.

btnOk = new JButton ("OK");btnOk.setBounds (20, 90, 100, 25);btnOk.addActionListener (this);btnCancel = new JButton ("Cancel");btnCancel.setBounds (150, 90, 100, 25);btnCancel.addActionListener (this);

//Adding All the Controls in Panel.pLog.add(rad);pLog.add(rcle);pLog.add(rmem);pLog.add (lbUser);pLog.add (lbPass);pLog.add (txtUser);pLog.add (txtPass);pLog.add (btnOk);pLog.add (btnCancel);

pLog.setBackground(c1);

//Adding Panel to the Form.

Page 28: Library Report

getContentPane().add (pLog); //pLog.getContentPane().setBackground(c1); //Opening the Database.

try {Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");String loc = "jdbc:odbc:Library";con = DriverManager.getConnection (loc);

}catch (ClassNotFoundException cnf) {

JOptionPane.showMessageDialog (null, "Driver not Loaded...");

System.exit (0);}catch (SQLException sqlex) {

JOptionPane.showMessageDialog (null, "Unable to Connect to Database..."); System.exit (0);

}

//Showing The Logon Form.

setVisible (true);

}

public void actionPerformed (ActionEvent ae) {

Object obj = ae.getSource();

if (obj == btnOk) { //If OK Button Pressed.

String password = new String (txtPass.getPassword());

if (txtUser.getText().equals ("")) {JOptionPane.showMessageDialog (this, "Provide Username

to Logon."); txtUser.requestFocus();} else if (password.equals ("")) {

Page 29: Library Report

txtPass.requestFocus(); JOptionPane.showMessageDialog (null,"Provide Password

to Logon.");}

else { String pass; //To Hold the Password. boolean verify = false; //To Confirm Logon. if(fl==1) {

if(txtUser.getText().equals("ADMIN")&&password.equals("ADMIN"))

{verify=true;

//JOptionPane.showMessageDialog(this,"Admin Logged in");new LibrarySystem(1,1,con);setVisible(false);dispose();

}}else{

String tablename=null;if(fl==2) tablename="Clerks";else if(fl==3)tablename="Members";

try { //SELECT Query to Retrieved the Record. String query = "SELECT * FROM " + tablename + " WHERE id = " + Integer.parseInt(txtUser.getText());

Statement st = con.createStatement (); //Creating Statement Object.

ResultSet rs = st.executeQuery (query); //Executing the Query.rs.next(); //Moving Towards the Record.

user = rs.getString ("id"); //Storing UserName. pass = rs.getString ("Password"); //Storing Password.

if (txtUser.getText().equals (“user”) && password.equals (“user”)) {//If Found then.

verify = true;

Page 30: Library Report

new LibrarySystem (fl,Integer.parseInt(txtUser.getText()), con);//Show Main Form.

//JOptionPane.showMessageDialog(this,"Correct Information Provided");setVisible (false); //Hide the Form.dispose(); //Free the System Resources.

}else {

verify = false;JOptionPane.showMessageDialog (this,

"Incorrect Information Provided.");txtUser.setText ("");txtPass.setText ("");txtUser.requestFocus ();

}}catch (Exception sqlex) {

if (verify == false) {JOptionPane.showMessageDialog (this,

"Incorrect excep Information Provided.");txtUser.setText ("");txtPass.setText ("");txtUser.requestFocus ();

}}

}

}}else if (obj == btnCancel) { //If Cancel Button Pressed Unload

the From.

setVisible (false);dispose();System.exit (0);

}else if(obj==rad){

fl=1;

Page 31: Library Report

}else if(obj==rcle){

fl=2;}else if(obj==rmem){

fl=3;}

}public static void main(String args[]){

Logon start=new Logon();}protected void loadSplashScreen(){

//Start the threadThFormSplash.start();while(!FormSplash.isShowing()){

try{//Display the FormSplash for 10 secondsThread.sleep(1000);

}catch(InterruptedException e){}

} }}class FrmSplash extends JWindow implements Runnable{

Dimension d = Toolkit.getDefaultToolkit().getScreenSize();public void run(){

JLabel SplashLabel = new JLabel("");Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

getContentPane().add(SplashLabel,BorderLayout.CENTER);

setSize(275,300);setLocation (d.width / 2 - getWidth() / 2, d.height / 2 - getHeight() / 2);setVisible(true);

}}

Page 32: Library Report

There are a number of classes created in this project whose coding can be explained as follows:

1. ADDBOOK.JAVA

import java.awt.*;import java.awt.event.*;

import javax.swing.*;

import java.sql.*;

public class AddBook extends JInternalFrame implements ActionListener, FocusListener {

private JPanel pBook = new JPanel ();private JLabel lbBookId, lbBookName, lbBookAuthor, lbBookRef,

lbBookCategory;private JTextField txtBookId, txtBookName, txtBookAuthor;private JComboBox cboBookCategory;private JButton btnOk, btnCancel;private JRadioButton rby,rbn;private ButtonGroup bg;private String[] cn =new String[100];private Statement st; //Statement for Getting the Required

Table.private long id = 0; //To Hold the BookId.private int i,j,ref=0;

Color c1=new Color(125,222,123); Color c2=new Color(125,222,223); Color c3=new Color(218,141,27); Color c4=new Color(234,11,179); Color c5=new Color(17,227,149); Color c6=new Color(63,185,60); Color c7=new Color(241,99,173); Color c8=new Color(253,232,243);

Page 33: Library Report

public AddBook (Connection con) {

//super (Title, Resizable, Closable, Maximizable, Iconifiable)super ("Add New Book", false, true, false, true);setSize (525, 450);

//Setting the Form's Labels.

lbBookId = new JLabel ("Book Id:");lbBookId.setForeground (Color.black);

lbBookId.setBackground (c1); lbBookId.setBounds (15, 15, 100, 20);

lbBookName = new JLabel ("Book Name:");lbBookName.setForeground (Color.black);

lbBookName.setBackground (c2); lbBookName.setBounds (15, 45, 100, 20);

lbBookAuthor = new JLabel ("Book Author:"); lbBookAuthor.setBackground (c3); lbBookAuthor.setForeground (Color.black);

lbBookAuthor.setBounds (15, 75, 100, 20);lbBookRef = new JLabel ("Reference:");

lbBookRef.setBackground (c4); lbBookRef.setForeground (Color.black);

lbBookRef.setBounds (15, 105, 100, 20);lbBookCategory = new JLabel ("Book Category:");

lbBookId.setBackground (c5); lbBookCategory.setForeground (Color.black);

lbBookCategory.setBounds (15, 135, 100, 20);

txtBookId = new JTextField ();txtBookId.setHorizontalAlignment (JTextField.RIGHT);txtBookId.addFocusListener (this);txtBookId.setBounds (120, 15, 175, 25);txtBookName = new JTextField ();txtBookName.setBounds (120, 45, 175, 25);txtBookAuthor = new JTextField ();txtBookAuthor.setBounds (120, 75, 175, 25);

rby=new JRadioButton("yes"); rby.setBackground(c7);

Page 34: Library Report

rby.addActionListener(this);rby.setBounds(120,105,60,25);rbn=new JRadioButton("no");

rbn.setBackground(c7);rbn.addActionListener(this);rbn.setBounds(180,105,60,25);bg = new ButtonGroup();bg.add(rby);bg.add(rbn);rbn.setSelected(true);

cboBookCategory = new JComboBox(); cboBookCategory.setBackground(c8);

cboBookCategory.setBounds (120, 135, 175, 25);

btnOk = new JButton ("OK");btnOk.setBounds (50, 175, 100, 25);

btnOk.setBackground(c4);btnOk.addActionListener (this);btnCancel = new JButton ("Cancel");

btnCancel.setBackground(c4);btnCancel.setBounds (170, 175, 100, 25);btnCancel.addActionListener (this);

txtBookId.addKeyListener (new KeyAdapter () {public void keyTyped (KeyEvent ke) {

char c = ke.getKeyChar ();if (! ((Character.isDigit (c)) || (c ==

KeyEvent.VK_BACK_SPACE))) {getToolkit().beep ();ke.consume ();

}}

});

txtBookAuthor.addKeyListener (new KeyAdapter () {public void keyTyped (KeyEvent ke) {

char c = ke.getKeyChar ();

Page 35: Library Report

if (! ((Character.isLetter (c)) || (c == KeyEvent.VK_BACK_SPACE)||(c == KeyEvent.VK_SPACE))) {

getToolkit().beep ();ke.consume ();//JOptionPane.showMessageDialog (null, "Enter only

Alphabets");}

}});

pBook.setLayout (null);pBook.add (lbBookId);pBook.add (lbBookName);pBook.add (lbBookAuthor);pBook.add (lbBookRef);pBook.add (lbBookCategory);pBook.add (txtBookId);pBook.add (txtBookName);pBook.add (txtBookAuthor);pBook.add (rby);pBook.add (rbn);//pBook.add (txtBookPrice);pBook.add (cboBookCategory);pBook.add (btnOk);pBook.add (btnCancel);

pBook.setBackground(c2);

getContentPane().add (pBook, BorderLayout.CENTER);

try {i=0;st = con.createStatement (); //Creating Statement Object.ResultSet rs=st.executeQuery("Select * from BCat");while(rs.next()){

cn[i]=rs.getString(1);i++;

}for(j=0;j<i;j++)

Page 36: Library Report

{cboBookCategory.addItem(cn[j]);

}cboBookCategory.addActionListener(this);cboBookCategory.setSelectedItem(cn[0]);rs.close();

}catch (SQLException sqlex) { //If Problem then Show the

User a Message. JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form."); dispose (); //Closing the Form.

}

setVisible (true);setLocation(110,110);

}

public void actionPerformed (ActionEvent ae) {

Object obj = ae.getSource();

if (obj == btnOk) { //If OK Button Pressed.

//Validating to Check All Required Information Provided or Not.

if (txtBookId.getText().equals ("")) {JOptionPane.showMessageDialog (this, "Book's Id not

Provided.");txtBookId.requestFocus ();

}else if (txtBookName.getText().equals ("")) {

JOptionPane.showMessageDialog (this, "Book's Name not Provided.");

txtBookName.requestFocus ();}else if (txtBookAuthor.getText().equals ("")) {

JOptionPane.showMessageDialog (this, "Book's Author Name not Provided.");

txtBookAuthor.requestFocus ();

Page 37: Library Report

}else{

try {int x = 0;

String s8 = x+"/"+x+"/"+x ;//INSERT Query to Add Book Record in Table./* String q = "INSERT INTO Books " +"VALUES (" + id + ", '" + txtBookName.getText() +

"', '" + txtBookAuthor.getText() + "', " + ref + ", '" +

cboBookCategory.getSelectedItem() + "' ,"+ 0 + ", '" + s8 + "', '" + s8 + ")"; */int result = st.executeUpdate ("Insert into Books

values("+ id +",'" + txtBookName.getText() +"','" + txtBookAuthor.getText() +"', " + ref + ", '" + cboBookCategory.getSelectedItem().toString() +"', " + 0 + ", '"+ s8 +"' ,'"+ s8 + "')"); //Running Query.

if (result == 1) { //If Query Successful.JOptionPane.showMessageDialog (this,

"Record has been Saved.");txtClear (); //Clearing the

TextFields.}else { //If Query Failed.

JOptionPane.showMessageDialog (this, "Problem while Saving the Record.");

}}catch (SQLException sqlex) {

JOptionPane.showMessageDialog (this, "Problem while Saving the Record Excep.");

}}

}

if (obj == btnCancel) { //If Cancel Button Pressed Unload the From.

setVisible (false);dispose();

Page 38: Library Report

}if(obj==rby){

ref=1;}else if(obj==rbn){

ref=0;}

}

public void focusGained (FocusEvent fe) { }

public void focusLost (FocusEvent fe) {

if (txtBookId.getText().equals ("")) { //If TextField is Empty.}else {

id = Integer.parseInt (txtBookId.getText ()); //Converting String to Numeric.

long bookNo; //Use for Comparing the Book's Id.

boolean found = false; //To Confirm the Book's Id Existance.

try { //SELECT Query to Retrieved the Record.String q = "SELECT * FROM Books WHERE BId = " + id

+ "";ResultSet rs = st.executeQuery (q); //Executing the Query.rs.next (); //Moving towards the Record.bookNo = rs.getLong ("BId"); //Storing the

Record.if (bookNo == id) { //If Record Found then

Display Message.found = true;txtClear (); //Clearing the TextFields.JOptionPane.showMessageDialog (this, id + " is

already assigned.");}

Page 39: Library Report

else {found = false;

}}catch (SQLException sqlex) {

//JOptionPane.showMessageDialog (this, "error!!.");}

}

}private void txtClear () {

txtBookId.setText ("");txtBookName.setText ("");txtBookAuthor.setText ("");cboBookCategory.setSelectedIndex(0);txtBookId.requestFocus ();}}

2.ADDCLERK.JAVA

import java.awt.*;import java.awt.event.*;

import javax.swing.*;

import java.sql.*;

public class AddClerk extends JInternalFrame implements ActionListener , FocusListener {

private JPanel pNew = new JPanel();private JLabel lbUser, lbPass,lbname;private JTextField txtUser,txtname;private JPasswordField txtPass;private JButton btnOk, btnCancel;private long id=0;private Statement st; //Statement for Getting the

Required Table. Color c1=new Color(125,222,123); Color c2=new Color(125,222,223);

Page 40: Library Report

Color c3=new Color(218,141,27); Color c4=new Color(234,11,179); Color c5=new Color(17,227,149); Color c6=new Color(63,185,60);

//Constructor of Class.

public AddClerk (Connection con) {

//super(title, resizable, closable, maximizable, iconifiable)super ("CREATE NEW CLERK", false, true, false, true);setSize (420, 400);//Setting the Form's Labels.

lbUser = new JLabel ("CLERK ID:");lbUser.setForeground (Color.black);lbUser.setBounds (20, 20, 100, 25);

lbname = new JLabel ("NAME:");lbname.setForeground (Color.black);

lbname.setBounds (20, 55, 100, 25);

lbPass = new JLabel ("PASSWORD:");lbPass.setForeground (Color.black);

lbPass.setBounds (20, 100, 100, 25);

txtUser = new JTextField ();txtUser.setBounds (100, 20, 150, 25);txtUser.setHorizontalAlignment (JTextField.RIGHT);

txtname = new JTextField ();txtname.setBounds (100, 55, 150, 25);txtname.setHorizontalAlignment (JTextField.RIGHT);txtname.addFocusListener (this); txtUser.addFocusListener (this);txtPass = new JPasswordField ();txtPass.setBounds (100, 100, 150, 25);

Page 41: Library Report

//Setting the Form's Buttons.

btnOk = new JButton ("OK");btnOk.setBounds (20, 130, 100, 25);btnOk.addActionListener (this);btnCancel = new JButton ("Cancel");btnCancel.setBounds (150, 130, 100, 25);btnCancel.addActionListener (this);

txtUser.addKeyListener (new KeyAdapter () {public void keyTyped (KeyEvent ke) {

char c = ke.getKeyChar ();if (! ((Character.isDigit (c)) || (c ==

KeyEvent.VK_BACK_SPACE))) {getToolkit().beep ();ke.consume ();

}}

});//Setting Panel's Layout.

pNew.setLayout (null);

//Adding All the Controls in Panel.

pNew.add (lbUser);pNew.add (lbname);

pNew.add(lbPass);pNew.add (txtUser);pNew.add (txtname);

pNew.add(txtPass); pNew.add (btnOk);pNew.add (btnCancel);

pNew.setBackground(c2);

//Adding Panel to the Form.

getContentPane().add (pNew);

Page 42: Library Report

try {st = con.createStatement (); //Creating Statement Object.

}catch (SQLException sqlex) { //If Problem then Show

the User a Message. JOptionPane.showMessageDialog (null, "A Problem

Occured While Loading the Form."); dispose (); //Closing the Form.

}

setVisible (true); setLocation(110,110);

}

public void actionPerformed (ActionEvent ae) {

Object obj = ae.getSource();

if (obj == btnOk) { //If OK Button Pressed.

String password = new String (txtPass.getPassword());

if (txtUser.getText().equals ("")) {txtUser.requestFocus();JOptionPane.showMessageDialog (this, "Username

not Provided.");}else if (password.equals ("")) {

txtPass.requestFocus();JOptionPane.showMessageDialog (this, "Password

not Provided.");}else {

try { //INSERT Query to Add Book Record in Table.String q = "INSERT INTO Clerks " +

"VALUES ('" + txtUser.getText() + "', '" + password + "','" + txtname.getText() + "')";

Page 43: Library Report

int result = st.executeUpdate (q); //Running Query.

if (result == 1) { //If Query Successful.

JOptionPane.showMessageDialog (this, "New Clerk has been Created.");

txtUser.setText ("");txtPass.setText ("");

txtname.setText(""); txtUser.requestFocus ();

}else { //If Query Failed.

JOptionPane.showMessageDialog (this, "Problem while Creating the User.");

txtUser.setText ("");txtPass.setText ("");

txtname.setText(" ");txtUser.requestFocus ();

}}catch (SQLException sqlex) { }

}

}

if (obj == btnCancel) { //If Cancel Button Pressed Unload the From.

setVisible (false);dispose();

}

}

public void focusGained (FocusEvent fe) { }

public void focusLost (FocusEvent fe) {

if (txtUser.getText().equals ("")) { //If TextField is Empty.

Page 44: Library Report

}else {

id = Integer.parseInt (txtUser.getText ()); //Converting String to Numeric.

long memberNo; //Use for Comparing the Member's Id.

boolean found = false; //To Confirm the Member's Id Existance.

try { //SELECT Query to Retrieved the Record.String q = "SELECT * FROM Clerks WHERE id = " + id +

"";ResultSet rs = st.executeQuery (q); //Executing the Query.rs.next (); //Moving towards the Record.memberNo = rs.getLong ("id"); //Storing the Record.if (memberNo == id) { //If Record Found then

Display Message.found = true;txtClear (); //Clearing the TextFields.JOptionPane.showMessageDialog (this, id + " is

already assigned.");}else {

found = false;}

}catch (SQLException sqlex) { }

}

}private void txtClear () {

txtUser.setText ("");txtPass.setText ("");

txtname.setText(" "); txtUser.requestFocus();

}}

Page 45: Library Report

3.ADDMEMBER.JAVA

import java.awt.*;import java.awt.event.*;import java.util.Calendar;import javax.swing.*;

import java.sql.*;import java.util.*;

public class AddMember extends JInternalFrame implements ActionListener, FocusListener {

private JPanel pMember = new JPanel ();private JLabel lbMemberId, lbMemberName, lbMemberpwd,

lbEntryDate,lbCategory;private JTextField txtMemberId, txtMemberName,

txtMemberpwd,txtMemberdate;private JButton btnOk, btnCancel;private JComboBox cboMemCategory;private Statement st; //Statement for Getting the Required

Table.private long id = 0;private String[] cn= new String[100]; int id1,im,iy,vd,vm,vy,i;

Color c1=new Color(125,222,123); Color c2=new Color(125,222,223); Color c3=new Color(218,141,27); Color c4=new Color(234,11,179); Color c5=new Color(17,227,149); Color c6=new Color(63,185,60);

public AddMember (Connection con) {

//super (Title, Resizable, Closable, Maximizable, Iconifiable)super ("Add New Member", false, true, false, true);setSize (455, 350);

//Setting the Form's Labels.

Page 46: Library Report

lbMemberId = new JLabel ("Member Id:");lbMemberId.setForeground (Color.black);lbMemberId.setBounds (15, 15, 100, 20);lbMemberName = new JLabel ("Member Name:");lbMemberName.setForeground (Color.black);lbMemberName.setBounds (15, 45, 100, 20);lbMemberpwd = new JLabel ("Member Pwd:");lbMemberpwd.setForeground (Color.black);lbMemberpwd.setBounds (15, 75, 110, 20);lbEntryDate = new JLabel ("Entry Date:");lbEntryDate.setForeground (Color.black);lbEntryDate.setBounds (15, 105, 100, 20);lbCategory = new JLabel ("Category:");lbCategory.setForeground(Color.BLACK);lbCategory.setBounds(15,135,100,20);

txtMemberId = new JTextField ();txtMemberId.setHorizontalAlignment (JTextField.RIGHT);txtMemberId.addFocusListener (this);txtMemberId.setBounds (125, 15, 205, 25);txtMemberName = new JTextField ();txtMemberName.setBounds (125, 45, 205, 25);txtMemberpwd = new JTextField ();txtMemberpwd.setBounds (125, 75, 205, 25);txtMemberdate=new JTextField();txtMemberdate.setBounds(125,105,205,25);txtMemberdate.setEditable(false);cboMemCategory= new JComboBox();

cboMemCategory.setBackground(c4); cboMemCategory.setBounds(125,135,100,20);

GregorianCalendar gcal=new GregorianCalendar(); id= gcal.get(Calendar.DATE); im=(int)gcal.get(Calendar.MONTH)+1; iy=gcal.get(Calendar.YEAR); String idate=id+"/"+im+"/"+iy; txtMemberdate.setText(idate);

Page 47: Library Report

btnOk = new JButton ("OK");btnOk.setBounds (30, 165, 125, 25);

btnOk.setBackground(c5);btnOk.addActionListener (this);btnCancel = new JButton ("Cancel");

btnCancel.setBackground(c5);btnCancel.setBounds (190, 165, 125, 25);btnCancel.addActionListener (this);

txtMemberId.addKeyListener (new KeyAdapter () {public void keyTyped (KeyEvent ke) {

char c = ke.getKeyChar ();if (! ((Character.isDigit (c)) || (c ==

KeyEvent.VK_BACK_SPACE))) {getToolkit().beep ();ke.consume ();

}}

});

txtMemberName.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent ke) { char c = ke.getKeyChar(); if (! ((Character.isLetter(c)) || (c == KeyEvent.VK_BACK_SPACE)||(c == KeyEvent.VK_SPACE))) { getToolkit().beep(); ke.consume(); //JOptionPane.showMessageDialog(null, "Enter only Alphabets"); } } } );

pMember.setLayout (null);pMember.add (lbMemberId);pMember.add (lbMemberName);pMember.add (lbMemberpwd);pMember.add (lbEntryDate);

Page 48: Library Report

pMember.add (txtMemberId);pMember.add (txtMemberName);pMember.add (txtMemberpwd);pMember.add(txtMemberdate);pMember.add (btnOk);pMember.add (btnCancel);pMember.add (lbCategory);pMember.add (cboMemCategory);pMember.setBackground(c2);

getContentPane().add (pMember, BorderLayout.CENTER);int j;try {

i=0;st = con.createStatement (); //Creating Statement Object.ResultSet rs=st.executeQuery("Select * from MeCat");while(rs.next()){

cn[i]=rs.getString(2);i++;

}for(j=0;j<i;j++){

cboMemCategory.addItem(cn[j]);}cboMemCategory.addActionListener(this);cboMemCategory.setSelectedItem(cn[0]);rs.close();

}catch (SQLException sqlex) { //If Problem then Show the

User a Message. JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form."); dispose (); //Closing the Form.

}

setVisible (true); setLocation(110,110);

}

Page 49: Library Report

public void actionPerformed (ActionEvent ae) {

Object obj = ae.getSource();

if (obj == btnOk) { //If OK Button Pressed.

//Validating to Check All Required Information Provided or Not.

if (txtMemberId.getText().equals ("")) {JOptionPane.showMessageDialog (this, "Member's Id not

Provided.");txtMemberId.requestFocus ();

}else if (txtMemberName.getText().equals ("")) {

JOptionPane.showMessageDialog (this, "Member's Name not Provided.");

txtMemberName.requestFocus ();}else if (txtMemberpwd.getText().equals ("")) {

JOptionPane.showMessageDialog (this, "Member's Password not Provided.");

txtMemberpwd.requestFocus ();}else {

try { //INSERT Query to Add Member Record in Table.int mtype=cboMemCategory.getSelectedIndex()+1;String q = "INSERT INTO Members" +

" VALUES (" + id + ", '" + txtMemberpwd.getText() + "', '" +

txtMemberName.getText() + "', '" + txtMemberdate.getText() + "',"+ 0 + "," + 0 + "," + mtype + ")";

int result = st.executeUpdate (q); //Running Query.if (result == 1) { //If Query Successful.

JOptionPane.showMessageDialog (this, "Record has been Saved.");

txtClear (); //Clearing the TextFields.

}

Page 50: Library Report

else { //If Query Failed.JOptionPane.showMessageDialog (this,

"Problem while Saving the Record.");}

}catch (SQLException sqlex)

{JOptionPane.showMessageDialog(this,"Error!!"); }

}}if (obj == btnCancel) { //If Cancel Button Pressed Unload the

From.

setVisible (false);dispose();

}}public void focusGained (FocusEvent fe) { }

public void focusLost (FocusEvent fe) {

if (txtMemberId.getText().equals ("")) { //If TextField is Empty.}else {

id = Integer.parseInt (txtMemberId.getText ()); //Converting String to Numeric.

long memberNo; //Use for Comparing the Member's Id.

boolean found = false; //To Confirm the Member's Id Existance.

try { //SELECT Query to Retrieved the Record.String q = "SELECT * FROM Members WHERE id = " + id +

"";ResultSet rs = st.executeQuery (q); //Executing the Query.rs.next (); //Moving towards the Record.memberNo = rs.getLong ("id"); //Storing the Record.

Page 51: Library Report

if (memberNo == id) { //If Record Found then Display Message.

found = true;txtClear (); //Clearing the TextFields.JOptionPane.showMessageDialog (this, id + " is already

assigned.");}else {

found = false;}

}catch (SQLException sqlex) { }

}

}

private void txtClear () {

txtMemberId.setText ("");txtMemberName.setText ("");txtMemberpwd.setText ("");txtMemberId.requestFocus ();

}}

4.AVAILBOOK.JAVA

import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import sun.jdbc.odbc.*;

public class availbook extends JFrame implements ActionListener { public JFrame f; JLabel l1; JTable table; JScrollPane sp;

Page 52: Library Report

int BID; int Password; String BNAME; String BAUTHOR; String BCAT; int BREF; int MID; int Mcat; Date BRETURN; Date BISSUE; String result; JButton b1;

public availbook() { f=new JFrame("BOOK INFORMATION REGISTER"); f.getContentPane().setLayout(new FlowLayout()); f.getContentPane().setBackground(new Color(205,39,155)); l1=new JLabel("BOOK AVAILABLE REGISTER"); l1.setFont(new Font("times new roman",Font.BOLD,34)); b1=new JButton("<-HOME"); b1.setMnemonic('b'); b1.addActionListener(this); f.add(l1); String url="jdbc:odbc:Library"; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(url); Statement stmt=conn.createStatement(); String sqlquery="SELECT BID,BNAME,BAUTHOR,BREF,BCAT,MID,BRETURN,BISSUE from Books WHERE MID= 0"; final Object[][] data=new Object[110][15]; ResultSet ps=stmt.executeQuery(sqlquery); System.out.println("rakesh"); result=" "; int i=0;

Page 53: Library Report

String row[]={"B_ID","B_NAME","B_AUTH","B_REF","B_CAT","M_ID","BRETURN","BISSUE"}; while(ps.next()) { data[i][0]=ps.getString(1); data[i][1]=ps.getString(2); data[i][2]=ps.getString(3); data[i][3]=ps.getString(4); data[i][4]=ps.getString(5); data[i][5]=ps.getString(6); data[i][6]=ps.getString(7); data[i][7]=ps.getString(8); i++; }

table=new JTable(data,row); sp=new JScrollPane(table); f.getContentPane().add(sp); f.add(b1); f.setSize(600,500); f.setVisible(true); f.setLocation(110,110); } catch(Exception e) { System.out.println(e);} } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) f.dispose(); } public static void main(String args[]) { new availbook(); } }

Page 54: Library Report

5.BOOKAUTHOR.JAVA

import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.Date;import sun.jdbc.odbc.*;

public class bookauthor extends JFrame implements ActionListener{ public JFrame f; public JFrame f1; JTable table; JScrollPane sp; JLabel l2=new JLabel("SERCHING BY AUTHOR"); public JButton b1; public JButton b2; public JButton b3; JTextField t1; JPanel out; JPanel labelpanel=new JPanel(); JPanel textpanel=new JPanel(); int count=0; public bookauthor() { f=new JFrame("**AUTHOR WISE SEARCH REGISTER**"); f.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f.getContentPane().setBackground(new Color(18,226,205)); labelpanel.setBackground(new Color(18,226,205)); b1=new JButton(" OK "); b2=new JButton("CANCEL"); b3=new JButton("<-HOME"); JLabel l=new JLabel("BOOK DETAILS"); JLabel l7=new JLabel(" "); JLabel l1=new JLabel("ENTER THE AUTHOR OF BOOK:"); l1.setFont(new Font("times new roman",Font.BOLD,17)); t1=new JTextField(10);

Page 55: Library Report

l1.setVerticalTextPosition(l1.BOTTOM); l1.setHorizontalTextPosition(l1.CENTER); f.add(l2); l2.setFont(new Font("times new roman",Font.BOLD,30)); labelpanel.add(l1); textpanel.add(t1); t1.addActionListener(this); t1.setToolTipText("For Eg. RAKESH"); b1.addActionListener(this); b2.addActionListener(this); labelpanel.setLayout(new BoxLayout(labelpanel,BoxLayout.Y_AXIS)); textpanel.setLayout(new BoxLayout(textpanel,BoxLayout.Y_AXIS)); f.getContentPane().add(labelpanel); f.getContentPane().add(textpanel); f.add(new JLabel(" ")); f.add(b1); f.add(new JLabel(" ")); f.add(b2); f.add(new JLabel(" ")); //f.getContentPane().add(jt,BorderLayout.SOUTH); f.setLocation(180,170); f.setSize(400,200); f.setVisible(true); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) { count=0; out=new JPanel(); f1=new JFrame("***BOOK INFORMATION***"); f1.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f1.getContentPane().setBackground(new Color(205,39,155)); f1.setSize(800,600); int book_id; String BOOK_NAME; String BOOK_AUTHOR; String BOOK_REF; String AVAIL; Date d1;

Page 56: Library Report

Date d2; String result; boolean test=false; String url="jdbc:odbc:Library"; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(url); Statement stmt=conn.createStatement(); String sqlquery="SELECT * FROM Books where BAUTHOR='"+t1.getText()+"'"; final Object[][]data=new Object[110][12]; ResultSet ps=stmt.executeQuery(sqlquery); result=" "; int i=0; String row[]={"book_id","BOOK_NAME","BOOK_AUTHOR","BREF","BOOK_CAT","AVAILABLE"}; while(ps.next()) { data[i][0]=ps.getString(1); data[i][1]=ps.getString(2); data[i][2]=ps.getString(3); data[i][3]=ps.getString(4); data[i][4]=ps.getString(5); AVAIL=ps.getString(6); test=AVAIL.equals("0"); if(test==true) { AVAIL="available"; data[i][5]=AVAIL; } else { AVAIL ="issue"; data[i][5]=AVAIL; } //data[i][5]=AVAIL;

i++;

Page 57: Library Report

} if(i>0) { table=new JTable(data,row); sp=new JScrollPane(table); f1.add(new JLabel(" ")); out.add(new JLabel(" ")); out.add(new JLabel(" OUTPUT ")); out.add(new JLabel(" ")); f1.getContentPane().add(out); out.setBackground(Color.yellow); f1.add(new JLabel(" ")); f1.getContentPane().add(sp); f1.getContentPane().add(b3); b3.addActionListener(this); f1.setVisible(true); t1.setText(""); JOptionPane.showMessageDialog(null,"RECORD FOUND","Message",JOptionPane.INFORMATION_MESSAGE); } else if(i==0) { JOptionPane.showMessageDialog(null,"Record is not AVAILABLE AUTHOR OF BOOK","Message",JOptionPane.INFORMATION_MESSAGE); } conn.close(); } catch(Exception e) { System.out.println(e);} } else {if(ae.getSource()==b2) { f.dispose(); } if(ae.getSource()==b3) { f1.dispose(); }

Page 58: Library Report

} }

/*public static void main(String args[]) { new find_4(); }*/ }

6.BOOKNAME.JAVA

import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.Date;import sun.jdbc.odbc.*;

public class bookname extends JFrame implements ActionListener{ public JFrame f; public JFrame f1; JTable table; JScrollPane sp; JLabel l2=new JLabel("SERCHING BY NAME"); public JButton b1; public JButton b2; public JButton b3; JTextField t1; JPanel out; JPanel labelpanel=new JPanel(); JPanel textpanel=new JPanel(); int count=0; public bookname() { f=new JFrame("**NAME WISE SEARCH REGISTER**"); f.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f.getContentPane().setBackground(new Color(18,226,205)); labelpanel.setBackground(new Color(18,226,205));

Page 59: Library Report

b1=new JButton(" OK "); b2=new JButton("CANCEL"); b3=new JButton("<-HOME"); JLabel l=new JLabel("BOOK DETAILS"); JLabel l7=new JLabel(" "); JLabel l1=new JLabel("ENTER THE NAME OF BOOK:"); l1.setFont(new Font("times new roman",Font.BOLD,17)); t1=new JTextField(10); l1.setVerticalTextPosition(l1.BOTTOM); l1.setHorizontalTextPosition(l1.CENTER); f.add(l2); l2.setFont(new Font("times new roman",Font.BOLD,30)); labelpanel.add(l1); textpanel.add(t1); t1.addActionListener(this); t1.setToolTipText("For Eg. JAVA"); b1.addActionListener(this); b2.addActionListener(this); labelpanel.setLayout(new BoxLayout(labelpanel,BoxLayout.Y_AXIS)); textpanel.setLayout(new BoxLayout(textpanel,BoxLayout.Y_AXIS)); f.getContentPane().add(labelpanel); f.getContentPane().add(textpanel); f.add(new JLabel(" ")); f.add(b1); f.add(new JLabel(" ")); f.add(b2); f.add(new JLabel(" ")); //f.getContentPane().add(jt,BorderLayout.SOUTH); f.setLocation(180,170); f.setSize(400,200); f.setVisible(true); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) { count=0; out=new JPanel(); f1=new JFrame("***BOOK INFORMATION***");

Page 60: Library Report

f1.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f1.getContentPane().setBackground(new Color(205,39,155)); f1.setSize(800,600); int book_id; String BOOK_NAME; String BOOK_AUTHOR; String BOOK_REF; String AVAIL; Date d1; Date d2; String result; boolean test=false; String url="jdbc:odbc:Library"; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(url); Statement stmt=conn.createStatement(); String sqlquery="SELECT * FROM Books where BName='"+t1.getText()+"'"; final Object[][]data=new Object[110][12]; ResultSet ps=stmt.executeQuery(sqlquery); result=" "; int i=0; String row[]={"book_id","BOOK_NAME","BOOK_AUTHOR","BREF","BOOK_CAT","AVAILABLE"}; while(ps.next()) { data[i][0]=ps.getString(1); data[i][1]=ps.getString(2); data[i][2]=ps.getString(3); data[i][3]=ps.getString(4); data[i][4]=ps.getString(5); AVAIL=ps.getString(6); test=AVAIL.equals("0"); if(test==true) { AVAIL="available"; data[i][5]=AVAIL;

Page 61: Library Report

} else { AVAIL ="issue"; data[i][5]=AVAIL; } //data[i][5]=AVAIL;

i++; } if(i>0) { table=new JTable(data,row); sp=new JScrollPane(table); f1.add(new JLabel(" ")); out.add(new JLabel(" ")); out.add(new JLabel(" OUTPUT ")); out.add(new JLabel(" ")); f1.getContentPane().add(out); out.setBackground(Color.yellow); f1.add(new JLabel(" ")); f1.getContentPane().add(sp); f1.getContentPane().add(b3); b3.addActionListener(this); f1.setVisible(true); t1.setText(""); JOptionPane.showMessageDialog(null,"RECORD FOUND","Message",JOptionPane.INFORMATION_MESSAGE); } else if(i==0) { JOptionPane.showMessageDialog(null,"Record is not available of Book NAME","Message",JOptionPane.INFORMATION_MESSAGE); } conn.close(); } catch(Exception e) { System.out.println(e);} }

Page 62: Library Report

else {if(ae.getSource()==b2) { f.dispose(); } if(ae.getSource()==b3) { f1.dispose(); } } }

/*public static void main(String args[]) { new find_4(); }*/}

7.BOOKTITLE.JAVA

import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.Date;import sun.jdbc.odbc.*;

public class booktitle extends JFrame implements ActionListener{ public JFrame f; public JFrame f1; JTable table; JScrollPane sp; JLabel l2=new JLabel("SERCHING BY TITLE"); public JButton b1; public JButton b2; public JButton b3; JTextField t1; JPanel out; JPanel labelpanel=new JPanel(); JPanel textpanel=new JPanel();

Page 63: Library Report

int count=0; public booktitle() { f=new JFrame("**TITLE WISE SEARCH REGISTER**"); f.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f.getContentPane().setBackground(new Color(18,226,205)); labelpanel.setBackground(new Color(18,226,205)); b1=new JButton(" OK "); b2=new JButton("CANCEL"); b3=new JButton("<-HOME"); JLabel l=new JLabel("BOOK DETAILS"); JLabel l7=new JLabel(" "); JLabel l1=new JLabel("ENTER THE TITLE OF BOOK:"); l1.setFont(new Font("times new roman",Font.BOLD,17)); t1=new JTextField(10); l1.setVerticalTextPosition(l1.BOTTOM); l1.setHorizontalTextPosition(l1.CENTER); f.add(l2); l2.setFont(new Font("times new roman",Font.BOLD,30)); labelpanel.add(l1); textpanel.add(t1); t1.addActionListener(this); t1.setToolTipText("For Eg. JAVA"); b1.addActionListener(this); b2.addActionListener(this); labelpanel.setLayout(new BoxLayout(labelpanel,BoxLayout.Y_AXIS)); textpanel.setLayout(new BoxLayout(textpanel,BoxLayout.Y_AXIS)); f.getContentPane().add(labelpanel); f.getContentPane().add(textpanel); f.add(new JLabel(" ")); f.add(b1); f.add(new JLabel(" ")); f.add(b2); f.add(new JLabel(" ")); //f.getContentPane().add(jt,BorderLayout.SOUTH); f.setLocation(180,170); f.setSize(400,200); f.setVisible(true); }

Page 64: Library Report

public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) { count=0; out=new JPanel(); f1=new JFrame("***BOOK INFORMATION***"); f1.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f1.getContentPane().setBackground(new Color(205,39,155)); f1.setSize(800,600); int book_id; String BOOK_NAME; String BOOK_AUTHOR; String BOOK_REF; String AVAIL; Date d1; Date d2; String result; boolean test=false; String url="jdbc:odbc:Library"; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(url); Statement stmt=conn.createStatement(); String sqlquery="SELECT * FROM Books where Bcat='"+t1.getText()+"'"; final Object[][]data=new Object[110][12]; ResultSet ps=stmt.executeQuery(sqlquery); result=" "; int i=0; String row[]={"book_id","BOOK_NAME","BOOK_AUTHOR","BREF","BOOK_CAT","AVAILABLE"}; while(ps.next()) { data[i][0]=ps.getString(1); data[i][1]=ps.getString(2); data[i][2]=ps.getString(3); data[i][3]=ps.getString(4);

Page 65: Library Report

data[i][4]=ps.getString(5); AVAIL=ps.getString(6); test=AVAIL.equals("0"); if(test==true) { AVAIL="available"; data[i][5]=AVAIL; } else { AVAIL ="issue"; data[i][5]=AVAIL; } //data[i][5]=AVAIL;

i++; } if(i>0) { table=new JTable(data,row); sp=new JScrollPane(table); f1.add(new JLabel(" ")); out.add(new JLabel(" ")); out.add(new JLabel(" OUTPUT ")); out.add(new JLabel(" ")); f1.getContentPane().add(out); out.setBackground(Color.yellow); f1.add(new JLabel(" ")); f1.getContentPane().add(sp); f1.getContentPane().add(b3); b3.addActionListener(this); f1.setVisible(true); t1.setText(""); JOptionPane.showMessageDialog(null,"RECORD FOUND","Message",JOptionPane.INFORMATION_MESSAGE); } else if(i==0) { JOptionPane.showMessageDialog(null,"Record is not available of Book TITLE","Message",JOptionPane.INFORMATION_MESSAGE);

Page 66: Library Report

} conn.close(); } catch(Exception e) { System.out.println(e);} } else {if(ae.getSource()==b2) { f.dispose(); } if(ae.getSource()==b3) { f1.dispose(); } } }

/*public static void main(String args[]) { new find_4(); }*/ }

8.CLERKID.JAVA

import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.Date;import sun.jdbc.odbc.*;

public class clerkid extends JFrame implements ActionListener{ public JFrame f; public JFrame f1; JTable table;

Page 67: Library Report

JScrollPane sp; JLabel l2=new JLabel("SERCHING BY C_ID"); public JButton b1; public JButton b2; public JButton b3; JTextField t1; JPanel out; JPanel labelpanel=new JPanel(); JPanel textpanel=new JPanel(); int count=0; public clerkid() { f=new JFrame("**CLERK REGISTER**"); f.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f.getContentPane().setBackground(new Color(18,226,205)); labelpanel.setBackground(new Color(18,226,205)); //jt.setBackground(Color.pink); b1=new JButton(" OK "); b2=new JButton("CANCEL"); b3=new JButton("<-HOME"); JLabel l=new JLabel("CLERK DETAILS"); JLabel l7=new JLabel(" "); JLabel l1=new JLabel("ENTER ID OF CLERK:"); l1.setFont(new Font("times new roman",Font.BOLD,17)); t1=new JTextField(10); l1.setVerticalTextPosition(l1.BOTTOM); l1.setHorizontalTextPosition(l1.CENTER); f.add(l2); l2.setFont(new Font("times new roman",Font.BOLD,30)); labelpanel.add(l1); textpanel.add(t1); t1.addActionListener(this); t1.setToolTipText("For Eg. 10"); b1.addActionListener(this); b2.addActionListener(this); labelpanel.setLayout(new BoxLayout(labelpanel,BoxLayout.Y_AXIS)); textpanel.setLayout(new BoxLayout(textpanel,BoxLayout.Y_AXIS)); f.getContentPane().add(labelpanel); f.getContentPane().add(textpanel); f.add(new JLabel(" "));

Page 68: Library Report

f.add(b1); f.add(new JLabel(" ")); f.add(b2); f.add(new JLabel(" ")); //f.getContentPane().add(jt,BorderLayout.SOUTH); f.setLocation(110,110); f.setSize(400,200); f.setVisible(true); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) { count=0; out=new JPanel(); f1=new JFrame("***CLERK INFORMATION***"); f1.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f1.getContentPane().setBackground(new Color(205,39,155)); f1.setSize(800,600); int clerkid; String password; boolean test=false; String url="jdbc:odbc:Library"; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(url); Statement stmt=conn.createStatement(); String sqlquery="SELECT id,password,name from Clerks WHERE ID="+Integer.parseInt(t1.getText())+""; final Object[][]data=new Object[110][12]; ResultSet ps=stmt.executeQuery(sqlquery); int i=0; String row[]={"CLERK_ID","CLERK_PASSWORD","CLERK_NAME"}; while(ps.next()) { data[i][0]=ps.getString(1);

Page 69: Library Report

data[i][1]=ps.getString(2); data[i][2]=ps.getString(3);

i++; } if(i>0) { table=new JTable(data,row); sp=new JScrollPane(table); f1.add(new JLabel(" ")); out.add(new JLabel(" ")); out.add(new JLabel(" OUTPUT ")); out.add(new JLabel(" ")); f1.getContentPane().add(out); out.setBackground(Color.yellow); f1.add(new JLabel(" ")); f1.getContentPane().add(sp); f1.getContentPane().add(b3); b3.addActionListener(this); f1.setVisible(true); t1.setText(""); JOptionPane.showMessageDialog(null,"RECORD FOUND","Message",JOptionPane.INFORMATION_MESSAGE); } else if(i==0) { JOptionPane.showMessageDialog(null,"Record is not available of Clerk ID","Message",JOptionPane.INFORMATION_MESSAGE); } conn.close(); } catch(Exception e) { System.out.println(e);} } else {if(ae.getSource()==b2) {

Page 70: Library Report

f.dispose(); } if(ae.getSource()==b3) { f1.dispose(); } } }

}

9.CLERKNAME.JAVA

import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.Date;import sun.jdbc.odbc.*;

public class clerkname extends JFrame implements ActionListener{ public JFrame f; public JFrame f1; JTable table; JScrollPane sp; JLabel l2=new JLabel("SERCHING BY C_NAME"); public JButton b1; public JButton b2; public JButton b3; JTextField t1; JPanel out; JPanel labelpanel=new JPanel(); JPanel textpanel=new JPanel(); int count=0; public clerkname() { f=new JFrame("**CLERK REGISTER**"); f.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f.getContentPane().setBackground(new Color(18,226,205));

Page 71: Library Report

labelpanel.setBackground(new Color(18,226,205)); //jt.setBackground(Color.pink); b1=new JButton(" OK "); b2=new JButton("CANCEL"); b3=new JButton("<-HOME"); JLabel l=new JLabel("CLERK DETAILS"); JLabel l7=new JLabel(" "); JLabel l1=new JLabel("ENTER NAME OF CLERK:"); l1.setFont(new Font("times new roman",Font.BOLD,17)); t1=new JTextField(10); l1.setVerticalTextPosition(l1.BOTTOM); l1.setHorizontalTextPosition(l1.CENTER); f.add(l2); l2.setFont(new Font("times new roman",Font.BOLD,30)); labelpanel.add(l1); textpanel.add(t1); t1.addActionListener(this); t1.setToolTipText("For Eg. RAJESH"); b1.addActionListener(this); b2.addActionListener(this); labelpanel.setLayout(new BoxLayout(labelpanel,BoxLayout.Y_AXIS)); textpanel.setLayout(new BoxLayout(textpanel,BoxLayout.Y_AXIS)); f.getContentPane().add(labelpanel); f.getContentPane().add(textpanel); f.add(new JLabel(" ")); f.add(b1); f.add(new JLabel(" ")); f.add(b2); f.add(new JLabel(" ")); //f.getContentPane().add(jt,BorderLayout.SOUTH); f.setLocation(180,170); f.setSize(400,200); f.setVisible(true); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) { count=0; out=new JPanel();

Page 72: Library Report

f1=new JFrame("***BOOK INFORMATION***"); f1.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); f1.getContentPane().setBackground(new Color(205,39,155)); f1.setSize(800,600); int clerk_id; String clerk_NAME; String password; String url="jdbc:odbc:Library"; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(url); Statement stmt=conn.createStatement(); String sqlquery="SELECT id,password,name from Clerks WHERE NAME='"+t1.getText()+"'"; final Object[][]data=new Object[110][12]; ResultSet ps=stmt.executeQuery(sqlquery); int i=0; String row[]={"CLERK_ID","PASSWORD","CLERK_NAME"}; while(ps.next()) { data[i][0]=ps.getString(1); data[i][1]=ps.getString(2); data[i][2]=ps.getString(3);

i++; } if(i>0) { table=new JTable(data,row); sp=new JScrollPane(table); f1.add(new JLabel(" ")); out.add(new JLabel(" ")); out.add(new JLabel(" OUTPUT "));

Page 73: Library Report

out.add(new JLabel(" ")); f1.getContentPane().add(out); out.setBackground(Color.yellow); f1.add(new JLabel(" ")); f1.getContentPane().add(sp); f1.getContentPane().add(b3); b3.addActionListener(this); f1.setVisible(true); t1.setText(""); JOptionPane.showMessageDialog(null,"RECORD FOUND","Message",JOptionPane.INFORMATION_MESSAGE); } else if(i==0) { JOptionPane.showMessageDialog(null,"Record is not available of CLERK Name","Message",JOptionPane.INFORMATION_MESSAGE); } conn.close(); } catch(Exception e) { System.out.println(e);} } else {if(ae.getSource()==b2) { f.dispose(); } if(ae.getSource()==b3) { f1.dispose(); } } }

}

10.DELETEBOOK.JAVA

Page 74: Library Report

import java.awt.*;import java.awt.event.*;

import javax.swing.*;

import java.sql.*;import java.util.*;

public class DeleteBook extends JInternalFrame implements ActionListener, FocusListener {

private JPanel pBook = new JPanel ();private JLabel lbBookId, lbBookName, lbBookAuthor;private JTextField txtBookId, txtBookName, txtBookAuthor;private JButton btnDel, btnCancel;

private Statement st; //Statement for Getting the Required Table.private ResultSet rs; //For Getting the Records From Table.private long id = 0,bisued; //To Hold the BookId.

Color c1=new Color(125,222,123); Color c2=new Color(125,222,223); Color c3=new Color(218,141,27); Color c4=new Color(234,11,179); Color c5=new Color(17,227,149); Color c6=new Color(63,185,60);

//Constructor of Class.

public DeleteBook (Connection con) {

//super (Title, Resizable, Closable, Maximizable, Iconifiable)super ("Delete Book", false, true, false, true);setSize (425, 400);

//Setting the Form's Labels.

lbBookId = new JLabel ("Book Id:");lbBookId.setForeground (Color.black);

Page 75: Library Report

lbBookId.setBounds (15, 15, 100, 20);lbBookName = new JLabel ("Book Name:");lbBookName.setForeground (Color.black);lbBookName.setBounds (15, 45, 100, 20);lbBookAuthor = new JLabel ("Book Author:");lbBookAuthor.setForeground (Color.black);lbBookAuthor.setBounds (15, 75, 100, 20);

txtBookId = new JTextField ();txtBookId.setHorizontalAlignment (JTextField.RIGHT);txtBookId.addFocusListener (this);txtBookId.setBounds (120, 15, 175, 25);txtBookName = new JTextField ();txtBookName.setEnabled (false);txtBookName.setBounds (120, 45, 175, 25);txtBookAuthor = new JTextField ();txtBookAuthor.setEnabled (false);txtBookAuthor.setBounds (120, 75, 175, 25);

btnDel = new JButton ("Delete Book");btnDel.setBounds (25, 175, 125, 25);btnDel.addActionListener (this);btnCancel = new JButton ("Cancel");btnCancel.setBounds (165, 175, 125, 25);btnCancel.addActionListener (this);

txtBookId.addKeyListener (new KeyAdapter () {public void keyTyped (KeyEvent ke) {

char c = ke.getKeyChar ();if (! ((Character.isDigit (c)) || (c ==

KeyEvent.VK_BACK_SPACE))) {getToolkit().beep ();ke.consume ();

}}

});

pBook.setLayout (null);pBook.add (lbBookId);

Page 76: Library Report

pBook.add (lbBookName);pBook.add (lbBookAuthor);

pBook.add (txtBookId);pBook.add (txtBookName);pBook.add (txtBookAuthor);

pBook.add (btnDel);pBook.add (btnCancel);

pBook.setBackground(c2);

getContentPane().add (pBook, BorderLayout.CENTER);

try {st = con.createStatement (); //Creating Statement Object.

}catch (SQLException sqlex) { //If Problem then Show the

User a Message. JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading the Form."); dispose (); //Closing the Form.

}

setVisible (true); setLocation(110,110);

}

public void actionPerformed (ActionEvent ae) {

Object obj = ae.getSource();

if (obj == btnDel) { //If Delete Button Pressed.

if (txtBookId.getText().equals ("")) {JOptionPane.showMessageDialog (this, "Book's Id not

Provided.");txtBookId.requestFocus ();

}else if(bisued!=0)

Page 77: Library Report

{txtClear();JOptionPane.showMessageDialog(this,"Book held by

a member");}

else{

//Show a Confirmation Dialog to Delete the Record. int reply = JOptionPane.showConfirmDialog (this,

"Are you really want to Delete\nthe " + txtBookName.getText () + " Record?",

"LibrarySystem - Delete Book", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE);

//Check the User Selection.if (reply == JOptionPane.YES_OPTION) { //If

User's Choice Yes then.

try { //DELETE Query to Delete Record From Table.String q = "DELETE FROM Books WHERE

BId = " + id + "";txtClear (); //Clering All

TextFields.JOptionPane.showMessageDialog (this, "Book

Deleted.");ResultSet rs = st.executeQuery (q); //Running

Query.}catch (SQLException sqlex) { }

}//If User's Choice No then Do Nothing Return to Program.else if (reply == JOptionPane.NO_OPTION) { }

}

}

if (obj == btnCancel) { //If Cancel Button Pressed Unload the From.

Page 78: Library Report

setVisible (false);dispose();

}

}

//OverRidding the FocusListener Class Function.

public void focusGained (FocusEvent fe) { }

public void focusLost (FocusEvent fe) {

if (txtBookId.getText().equals ("")) { //If TextField is Empty.}else {

id = Integer.parseInt (txtBookId.getText ()); //Converting String to Numeric.

long bookNo; //Use for Comparing the Book's Id.

boolean found = false; //To Confirm the Book's Id Existance.

try { //SELECT Query to Retrieved the Record.

String q = "SELECT * FROM Books WHERE BId = " + id + "";

ResultSet rs = st.executeQuery (q); //Executing the Query.rs.next (); //Moving towards the Record.bookNo = rs.getLong ("BId"); //Storing the

Record.bisued=rs.getLong("Mid");

if (bookNo == id) {found = true;txtBookId.setText ("" + id);txtBookName.setText ("" + rs.getString ("BName"));txtBookAuthor.setText ("" + rs.getString

("BAuthor"));

Page 79: Library Report

}else {

found = false;}

}catch (SQLException sqlex) {

if (found == false) {txtClear (); //Clearing the TextFields.JOptionPane.showMessageDialog (this, "Record not

Found.");}

}}

}

//Function Use to Clear All the TextFields of Form.

private void txtClear () {

txtBookId.setText ("");txtBookName.setText ("");txtBookAuthor.setText ("");txtBookId.requestFocus();

}}

11.DELETEMEMBER.JAVA

import java.awt.*;import java.awt.event.*;

import javax.swing.*;

import java.sql.*;

public class DeleteMember extends JInternalFrame implements ActionListener, FocusListener {

private JPanel pMember = new JPanel ();private JLabel lbMemberId, lbMemberName,lbMemberCat;

Page 80: Library Report

private JTextField txtMemberId, txtMemberName,txtCat;private JButton btnDel, btnCancel;private int due;private Statement st; //Statement for Getting the Required Table.private ResultSet rs; //For Getting the Records From Table.private long id = 0,heldBooks; //To Hold the MemberId.

Color c1=new Color(125,222,123); Color c2=new Color(125,222,223); Color c3=new Color(218,141,27); Color c4=new Color(234,11,179); Color c5=new Color(17,227,149); Color c6=new Color(63,185,60);

//Constructor of Class.

public DeleteMember (Connection con) {

//super (Title, Resizable, Closable, Maximizable, Iconifiable)super ("Delete Member", false, true, false, true);setSize (425, 400);

//Setting the Form's Labels.

lbMemberId = new JLabel ("Member Id:");lbMemberId.setForeground (Color.black);lbMemberId.setBounds (15, 15, 100, 20);lbMemberName = new JLabel ("Member Name:");lbMemberName.setForeground (Color.black);lbMemberName.setBounds (15, 45, 100, 20);lbMemberCat = new JLabel ("Category");lbMemberCat.setForeground (Color.black);lbMemberCat.setBounds (15, 75, 110, 20);

txtMemberId = new JTextField ();txtMemberId .setHorizontalAlignment (JTextField.RIGHT);txtMemberId.addFocusListener (this);txtMemberId .setBounds (125, 15, 200, 25);txtMemberName = new JTextField ();txtMemberName.setEnabled (false);

Page 81: Library Report

txtMemberName.setBounds (125, 45, 200, 25);txtCat = new JTextField ();txtCat.setEnabled (false);txtCat.setBounds (125, 75, 200, 25);btnDel = new JButton ("Delete Member");btnDel.setBounds (30, 145, 125, 25);btnDel.addActionListener (this);btnCancel = new JButton ("Cancel");btnCancel.setBounds (185, 145, 125, 25);btnCancel.addActionListener (this);

//Registering the KeyListener to Restrict user to type only Numeric in Numeric Boxes.

txtMemberId.addKeyListener (new KeyAdapter () {public void keyTyped (KeyEvent ke) {

char c = ke.getKeyChar ();if (! ((Character.isDigit (c)) || (c ==

KeyEvent.VK_BACK_SPACE))) {getToolkit().beep ();ke.consume ();

}}

});

//Adding All the Controls in Panel.

pMember.setLayout (null);pMember.add (lbMemberId);pMember.add (lbMemberName);pMember.add(lbMemberCat);pMember.add(txtCat);

pMember.add (txtMemberId);pMember.add (txtMemberName);

pMember.add (btnDel);pMember.add (btnCancel);

pMember.setBackground(c2);

Page 82: Library Report

//Adding Panel to Form.

getContentPane().add (pMember, BorderLayout.CENTER);

try {st = con.createStatement (); //Creating Statement Object.

}catch (SQLException sqlex) { //If Problem then Show the

User a Message. JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading the Form."); dispose (); //Closing the Form.

}

setVisible (true); setLocation(110,110);

}

public void actionPerformed (ActionEvent ae) {

Object obj = ae.getSource();

if (obj == btnDel) { //If Delete Button Pressed.

if (txtMemberId.getText().equals ("")) {JOptionPane.showMessageDialog (this, "Member's Id not

Provided.");txtMemberId.requestFocus ();

}else if(heldBooks!=0) { JOptionPane.showMessageDialog(this,"Member Holding

Books..Can't Delete"); txtClear(); }else if(due!=0){

Page 83: Library Report

JOptionPane.showMessageDialog(this,"Member Holding Books..Can't Delete");

txtClear();

}else{

int reply = JOptionPane.showConfirmDialog (this, "Do you really want to Delete\nthe " +

txtMemberName.getText () + " Record?","LibrarySystem - Delete Member",

JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE);

//Check the User Selection.if (reply == JOptionPane.YES_OPTION) {

//If User's Choice Yes then.

try { //DELETE Query to Delete the Record from Table.

String q = "DELETE FROM Members WHERE id = " + id + "";

txtClear (); //Clearing the TextFields.

JOptionPane.showMessageDialog (this, "Record has been Deleted.");

ResultSet rs = st.executeQuery (q); //Executing the Query.

}catch (SQLException sqlex)

{System.out.println("problem"); }

}//If User's Choice No then Do Nothing Return to Program.else if (reply == JOptionPane.NO_OPTION) { }

}

}

Page 84: Library Report

if (obj == btnCancel) { //If Cancel Button Pressed Unload the From.

setVisible (false);dispose();

}

}

//OverRidding the FocusListener Class Function.

public void focusGained (FocusEvent fe) { }

public void focusLost (FocusEvent fe) {

if (txtMemberId.getText().equals ("")) { //If TextField is Empty.}else {

id = Integer.parseInt (txtMemberId.getText ()); //Converting String to Numeric.

long memberNo,memtype; //Use for Comparing the Member's Id.

boolean found = false; //To Confirm the Member's Id Existance.

try { //SELECT Query to Retrieved the Record.String q = "SELECT * FROM Members WHERE id = " +

id + "";ResultSet rs = st.executeQuery (q); //Executing the Query.rs.next (); //Moving towards the Record.memberNo = rs.getLong ("id"); //Storing the Record.heldBooks=rs.getLong("Bcnt");due=rs.getInt(6);memtype=rs.getLong("Mcat");if (memberNo == id) { //If Record Found then

Display Records.

found = true;txtMemberId.setText ("" + id);

Page 85: Library Report

txtMemberName.setText ("" + rs.getString ("MName"));

ResultSet rs1=st.executeQuery("Select * From MeCat where Mcat="+memtype+"");

rs1.next();txtCat.setText(""+rs1.getString("CName"));

}else {

found = false;}

}catch (SQLException sqlex) {

if (found == false) {txtClear (); //Clearing the TextFields.JOptionPane.showMessageDialog (this, "Record not

Found.");}

}

}

}

//Function Use to Clear All the TextFields of Form.

private void txtClear () {

txtMemberId.setText ("");txtMemberName.setText ("");txtCat.setText("");txtMemberId.requestFocus ();

}

}

12.ISSUEBOOK1.JAVA

import javax.swing.*;

Page 86: Library Report

import java.awt.*;import java.awt.event.*;import java.sql.*;import sun.jdbc.odbc.*;

public class issueBook1 extends JFrame implements ActionListener { public JFrame f; JLabel l1; JTable table; JScrollPane sp; int BID; int Password; String BNAME; String BAUTHOR; String BCAT; int BREF; int MID; int Mcat; Date BRETURN; Date BISSUE; String result; JButton b1;

public issueBook1() { f=new JFrame("ISSUE BOOK REGISTER"); f.getContentPane().setLayout(new FlowLayout()); f.getContentPane().setBackground(new Color(205,39,155)); l1=new JLabel("ISSUE BOOK DETAIL"); l1.setFont(new Font("times new roman",Font.BOLD,34)); b1=new JButton("<-HOME"); b1.setMnemonic('b'); b1.addActionListener(this); f.add(l1); String url="jdbc:odbc:Library"; try {

Page 87: Library Report

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection(url); Statement stmt=conn.createStatement(); String sqlquery="SELECT BID,BNAME,BAUTHOR,BREF,BCAT,MID,BRETURN,BISSUE from Books WHERE MID> 0"; final Object[][] data=new Object[110][15]; ResultSet ps=stmt.executeQuery(sqlquery); System.out.println("rakesh"); result=" "; int i=0; String row[]={"B_ID","B_NAME","B_AUTH","B_REF","B_CAT","M_ID","BRETURN","BISSUE"}; while(ps.next()) { data[i][0]=ps.getString(1); data[i][1]=ps.getString(2); data[i][2]=ps.getString(3); data[i][3]=ps.getString(4); data[i][4]=ps.getString(5); data[i][5]=ps.getString(6); data[i][6]=ps.getString(7); data[i][7]=ps.getString(8); i++; }

table=new JTable(data,row); sp=new JScrollPane(table); f.getContentPane().add(sp); f.add(b1); f.setSize(600,500); f.setVisible(true); f.setLocation(110,110); } catch(Exception e) { System.out.println(e);} }

Page 88: Library Report

public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) f.dispose(); } public static void main(String args[]) { new issueBook1(); } }

13.RETURNBOOK.JAVA

import java.io.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;

import java.util.Date;import java.util.Calendar;import java.util.*;import java.text.SimpleDateFormat;import java.sql.*;

public class ReturnBook extends JInternalFrame implements ActionListener, FocusListener {

private JPanel pBook = new JPanel ();private JLabel lbBookId, lbBookName,lbIssued;private JTextField txtBookId, txtBookName, txtIssued;private String urdate;private JButton btnReturn, btnCancel;private int id1,im,iy,vd,vm,vy,due;private Statement st; //Statement for Getting the Required Table.private ResultSet rs; //For Getting the Records From Table.private long id = 0; //To Hold the BookId.private int mid,bc;

Color c1=new Color(125,222,123); Color c2=new Color(125,222,223); Color c3=new Color(218,141,27);

Page 89: Library Report

Color c4=new Color(234,11,179); Color c5=new Color(17,227,149); Color c6=new Color(63,185,60);

public ReturnBook (Connection con) {

//super (Title, Resizable, Closable, Maximizable, Iconifiable)super ("RETURN BOOK", false, true, false, true);setSize (400, 300);

//Setting the Form's Labels.

lbBookId = new JLabel ("BOOK ID:");lbBookId.setForeground (Color.black);lbBookId.setBounds (15, 15, 100, 20);lbBookName = new JLabel ("BOOK NAME:");lbBookName.setForeground (Color.black);lbBookName.setBounds (15, 45, 100, 20);lbIssued = new JLabel ("BOOK ISSUED TO:");lbIssued.setForeground (Color.black);lbIssued.setBounds (15, 75, 100, 20);

txtBookId = new JTextField ();txtBookId.setHorizontalAlignment (JTextField.RIGHT);txtBookId.addFocusListener (this);txtBookId.setBounds (120, 15, 175, 25);txtBookName = new JTextField ();txtBookName.setEnabled (false);txtBookName.setBounds (120, 45, 175, 25);txtIssued = new JTextField ();txtIssued.setEnabled (false);txtIssued.setBounds (120, 75, 175, 25);

btnReturn = new JButton ("RETURN BOOK");btnReturn.setBounds (25, 175, 125, 25);btnReturn.addActionListener (this);btnCancel = new JButton ("Cancel");btnCancel.setBounds (165, 175, 125, 25);btnCancel.addActionListener (this);

Page 90: Library Report

txtBookId.addKeyListener (new KeyAdapter () {public void keyTyped (KeyEvent ke) {

char c = ke.getKeyChar ();if (! ((Character.isDigit (c)) || (c ==

KeyEvent.VK_BACK_SPACE))) {getToolkit().beep ();ke.consume ();

}}

});

pBook.setLayout (null);pBook.add (lbBookId);pBook.add (lbBookName);pBook.add (lbIssued);pBook.add (txtBookId);pBook.add (txtBookName);pBook.add (txtIssued);pBook.add (btnReturn);pBook.add (btnCancel);

pBook.setBackground(c2);

getContentPane().add (pBook, BorderLayout.CENTER);

try {st = con.createStatement (); //Creating Statement Object.

}catch (SQLException sqlex) { //If Problem then Show the

User a Message. JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading the Form."); dispose (); //Closing the Form.

}GregorianCalendar gcal=new GregorianCalendar();

id1= gcal.get(Calendar.DATE); im=(int)gcal.get(Calendar.MONTH)+1; iy=gcal.get(Calendar.YEAR); String xx,yy,zz;

Page 91: Library Report

if(id1<10) { xx="0"+id1; } else { xx = ""+id1; } if(im<10) { yy="0"+im; } else { yy = ""+im; } urdate=xx+"/"+yy+"/"+iy;

setVisible (true); setLocation(110,110);

}

public void actionPerformed (ActionEvent ae) {

Object obj = ae.getSource();

if (obj == btnReturn) { //If Return Button Pressed.

if (txtBookId.getText().equals ("")) {JOptionPane.showMessageDialog (this, "Book's Id not

Provided.");txtBookId.requestFocus ();

}else {

try {int rd,rm,ry,urd,urm,ury,x;long v,v1,fine;Dates d1,d2;bc--;id = Integer.parseInt (txtBookId.getText ());ResultSet rs = st.executeQuery ("select * from Books

WHERE BId ="+id+""); //Executing the Query.rs.next();String ard=rs.getString("BReturn");System.out.println("came here 1");rs.close();

Page 92: Library Report

String sr=urdate; StringTokenizer st2 = new StringTokenizer(sr,"/"); urd=Integer.parseInt(st2.nextToken()); urm=Integer.parseInt(st2.nextToken()); ury=Integer.parseInt(st2.nextToken()); d2= new Dates(urm,urd,ury); StringTokenizer st1 = new StringTokenizer(ard,"/");

rd=Integer.parseInt(st1.nextToken()); rm=Integer.parseInt(st1.nextToken()); ry=Integer.parseInt(st1.nextToken()); d1=new Dates(rm,rd,ry); v = d1.toLong(); v1 = d2.toLong(); fine=v1-v; if(fine<=0) fine=0; else { int reply = JOptionPane.showConfirmDialog (this, "Will you pay the Fine of Rs."+fine+"now","FinePay", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE); if (reply == JOptionPane.YES_OPTION) {} else if (reply == JOptionPane.NO_OPTION) { due+=fine; } } x=st.executeUpdate("Update Books Set Mid ="+0+",BReturn="+0+",BIssue="+0+" WHERE Bid ="+id+"");

Page 93: Library Report

x=st.executeUpdate("Update Members Set Bcnt ="+bc+", Mbdues="+due+" WHERE id ="+mid+""); JOptionPane.showMessageDialog (this, "Book Returned"); txtClear();

}catch (SQLException sqlex) {

JOptionPane.showMessageDialog (this, "Problem");}

}

}

if (obj == btnCancel) { //If Cancel Button Pressed Unload the From.

setVisible (false);dispose();

}

}

public void focusGained (FocusEvent fe) { }

public void focusLost (FocusEvent fe) {

if (txtBookId.getText().equals ("")) { //If TextField is Empty.}else {

id = Integer.parseInt (txtBookId.getText ()); //Converting String to Numeric.

long bookNo; //Use for Comparing the Book's Id.

boolean found = false; //To Confirm the Book's Id Existance.

try { //SELECT Query to Retrieved the Record./*String q = "SELECT IssuedBooks.BookId,

IssuedBooks.BookName, IssuedBooks.BookAuthor, " +

Page 94: Library Report

"IssuedBooks.Category, Members.MemberName FROM IssuedBooks " +

"INNER JOIN Members ON IssuedBooks.MemberId = Members.MemberId " +

"WHERE BookId = " + id + ""; */ResultSet rs = st.executeQuery ("Select * from Books where

BId="+id+""); //Executing the Query.rs.next (); //Moving towards the Record.bookNo = rs.getLong ("BId"); //Storing the

Record.if (bookNo == id) { //If Record Found then

Display Records.found = true;txtBookId.setText ("" + id);txtBookName.setText ("" + rs.getString ("BName"));mid=rs.getInt("Mid");if(mid==0){

JOptionPane.showMessageDialog(this,"Not an Issued Book");

dispose();}else{

ResultSet rs1=st.executeQuery("Select * from Members where id="+mid+"");

rs1.next();txtIssued.setText ("" + rs1.getString (3));bc=rs1.getInt("Bcnt");due=rs1.getInt(6);

}}else {

found = false;}

}catch (SQLException sqlex) {

if (found == false) {txtClear (); //Clearing the TextFields.

Page 95: Library Report

JOptionPane.showMessageDialog (this, "Record not Found.");

}}

}

}

//Function Use to Clear All the TextFields of Form.

private void txtClear () {

txtBookId.setText ("");txtBookName.setText ("");txtIssued.setText ("");txtBookId.requestFocus ();

}}

14.SEARCHBOOK.JAVA

import java.awt.*;import java.awt.event.*;

import javax.swing.*;

import java.sql.*;

public class SearchBook extends JInternalFrame implements ActionListener {

private JPanel pBook = new JPanel ();private JLabel lbSearch;private JRadioButton rb1,rb2,rb3,rb4;private JTextField txtSearch;private JButton btnFind, btnCancel;private int flag=0;private Statement st;

Page 96: Library Report

private String bname,bauthor,bcat,search;private int bref,bmid,bid,rows=0;private JTable table;private JScrollPane jsp;private Object data1[][];private Container c;

Color c1=new Color(125,222,123); Color c2=new Color(125,222,223); Color c3=new Color(218,141,27); Color c4=new Color(184,198,19); Color c5=new Color(17,227,149); Color c6=new Color(63,185,60);

public SearchBook (Connection con) {

//super (Title, Resizable, Closable, Maximizable, Iconifiable)super ("Search Books", false, true, false, true);setSize (510, 300);

//Setting the Form's Labels.

lbSearch = new JLabel ("Search Field");lbSearch.setForeground (Color.black);lbSearch.setBounds (15, 15, 100, 20);

txtSearch = new JTextField ();txtSearch.setBounds (120, 15, 175, 25);

btnFind = new JButton ("Find Book");btnFind.setBounds (25, 175, 125, 25);btnFind.addActionListener (this);btnCancel = new JButton ("Cancel");btnCancel.setBounds (165, 175, 125, 25);btnCancel.addActionListener (this);

rb1=new JRadioButton("By Title"); rb1.setBackground(c4);

rb1.addActionListener(this);rb1.setBounds (15, 45, 100, 20);rb2=new JRadioButton("By Author");

Page 97: Library Report

rb2.setBackground(c4); rb2.addActionListener(this);rb2.setBounds (15, 75, 100, 20);rb3=new JRadioButton("By Category");

rb3.setBackground(c4); rb3.addActionListener(this);rb3.setBounds (15, 105, 100, 20);rb4=new JRadioButton("By id");

rb4.setBackground(c4); rb4.addActionListener(this);rb4.setBounds(15,135,100,20);

pBook.setLayout (null);pBook.add(lbSearch);pBook.add(txtSearch);pBook.add(btnFind);pBook.add(btnCancel);ButtonGroup bg=new ButtonGroup();bg.add(rb1);bg.add(rb2);bg.add(rb3);bg.add(rb4);pBook.add(rb1);pBook.add(rb2);pBook.add(rb3);pBook.add(rb4);

pBook.setBackground(c2);rb1.setSelected(true);getContentPane().add (pBook, BorderLayout.CENTER);c=getContentPane();

try {st = con.createStatement (); //Creating Statement Object.

}catch (SQLException sqlex) { //If Problem then Show the

User a Message. JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form."); dispose (); //Closing the Form.

}

Page 98: Library Report

setVisible (true); setLocation(110,110);

}

public void actionPerformed (ActionEvent ae) {

Object obj = ae.getSource();

if (obj == btnFind) { //If Find Button Pressed.

if (txtSearch.getText().equals ("")) {JOptionPane.showMessageDialog (this, "Search Field not

Provided.");txtSearch.requestFocus ();

}else {

String bname1,bauthor1,bcat1;int num;boolean found = false; //To Confirm the

Book's Id Existance.

try { //SELECT Query to Retrieved the Record.String q,bavl,bisr;num=st.executeUpdate("Delete * from BSearch");ResultSet rs = st.executeQuery ("SELECT * FROM

Books "); //Executing the Query.

search=txtSearch.getText();search=search.toLowerCase();

while(rs.next()){

bname=rs.getString(2);bauthor=rs.getString("BAuthor");

Page 99: Library Report

bcat=rs.getString("BCat");bref=rs.getInt("BRef");if(bref==1) bisr="Yes";else bisr="No";bmid=rs.getInt("Mid");if(bmid==0) bavl="Available";else bavl="Issued:"+ bmid;bid=rs.getInt("BId");

if(flag==0){

bname1=bname.toLowerCase();if(bname1.equals(search)||

(bname1.indexOf(search)!=-1)){

System.out.println("Came Here2"); num=st.executeUpdate("insert into

BSearch values("+bid+", '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"', '"+bisr+"')");

rows++; found=true;}

}else if(flag==1){

bauthor1=bauthor.toLowerCase();if(bauthor1.equals(search)||

(bauthor1.indexOf(search)!=-1)){

num=st.executeUpdate("insert into BSearch values("+bid+", '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"', '"+bisr+"')");

rows++;found=true;

}}else if(flag==2){

bcat1=bcat.toLowerCase();

Page 100: Library Report

if(bcat1.equals(search)||(bcat1.indexOf(search)!=-1))

{num=st.executeUpdate("insert into

BSearch values("+bid+", '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"', '"+bisr+"')");

rows++;found=true;

}}else if(flag==3){

if(bid==Integer.parseInt(txtSearch.getText())){

rows++;num=st.executeUpdate("insert into

BSearch values("+bid+", '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"', '"+bisr+"')");

found=true;

}}

}/* data1=new Object[rows][6];

System.out.println("hadsfdsfi i came here");Object[] Colheads={"Book Id","Book

Name","Category","Author","Availability","Reference"};rs=st.executeQuery("Select * from BSearch");System.out.println("hai i came here");for(int i1=0;i1<rows;i1++){

rs.next();for(int j1=0;j1<6;j1++){

data1[i1][j1]=rs.getString(j1);}

}

Page 101: Library Report

table=new JTable(data1,Colheads);int

v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;int

h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;System.out.println("hai we came here");jsp=new JScrollPane(table,v,h);TableDisp td=new TableDisp(jsp);txtSearch.setText("");txtSearch.requestFocus();*/

}catch(SQLException sqlex) {

if (found == false) {JOptionPane.showMessageDialog (this,

"Record not Found.");}

}try{data1=new Object[rows][6];

Object[] Colheads={"Book Id","Book Name","Category","Author","Availability","Reference"};

ResultSet rs=st.executeQuery("Select * from BSearch");

for(int i1=0;i1<rows;i1++){

rs.next();for(int j1=0;j1<6;j1++){

data1[i1][j1]=rs.getString(j1+1);}

}table=new JTable(data1,Colheads);int

v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;int

h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;System.out.println("hai we came here");

Page 102: Library Report

jsp=new JScrollPane(table,v,h);TableDisp td=new TableDisp(table);

}catch(Exception sqlex) {

if (found == false) {JOptionPane.showMessageDialog (this, "Some

prob Found.");}

}}

}

if (obj == btnCancel) { //If Cancel Button Pressed Unload the From.

setVisible (false);dispose();

}

if(obj==rb1){

flag=0;}if(obj==rb2){

flag=1;}if(obj==rb3){

flag=2;}if(obj==rb4){

flag=3;}

Page 103: Library Report

}

}

Page 104: Library Report

OUTPUT SNAPSHOTS

Page 105: Library Report

This is the main window of the project

Page 106: Library Report

If we want to add new book.

Page 107: Library Report

Inorder to change the background colour

Page 108: Library Report

Bibiliography

References used are:

Java TM programming language SL-275-SE6 Entire book-bank of NIIT Through various search engines on net. The complete java