Java Topics
HubJava Collections FrameworkCollections Practice ProgramsComparable vs ComparatorGenericsIteratorArrayListLinkedListStackVectorHashMapHashtableLinkedHashMapTreeMapArrayDequeDeque Double-Ended QueuePriorityQueueHashSetLinkedHashSetTreeSetAdapter PatternBuilder PatternFactory PatternMVC PatternObserver PatternSingleton PatternDynamic ProgrammingGraphHashingHeapLinked List DSAQueue DSARecursionSearching AlgorithmsSorting AlgorithmsStack DSATime ComplexityTreesException Handling Best PracticesCustom ExceptionException Hierarchyfinally BlockException Handlingthrow aur throwstry-catchBuffered StreamsByte StreamsCharacter StreamsDeserializationFile ClassJava NIO New I/OSerializationArrays in JavaArray OperationsArray Practice ProgramsArray Interview QuestionsJagged ArrayMulti-Dimensional ArraysOne Dimensional Arraybreak aur continuedo-while Loopfor Loopif-else StatementsNested Loopsswitch-case Statementwhile LoopJava Compilation ProcessJava ki FeaturesPehla Java ProgramHistory of JavaJava EditionsJava Program StructureJDK, JRE aur JVMJava Kya Hai?Immutable StringsString Class in JavaString Interview QuestionsString MethodsString Practice ProgramsStringBufferStringBuilderComments in JavaData Types in JavaIdentifiers in JavaInput & Output in JavaJava KeywordsOperators in JavaType Casting in JavaVariables in JavaJava Coding Interview QuestionsCollections Interview QuestionsCore Java Interview QuestionsJDBC Interview QuestionsMultithreading Interview QuestionsOOPs Interview QuestionsSpring Framework Interview QuestionsJava 8 Date/Time APIDefault aur Static Methods in InterfaceFunctional InterfaceLambda ExpressionMethod ReferenceOptional ClassStream APIBatch ProcessingCallableStatementJDBC ArchitectureJDBC — Java Database ConnectivityJDBC Practice ProjectsMySQL ConnectionPreparedStatementResultSetStatement InterfaceTransaction ManagementCreating ThreadsDaemon ThreadExecutor FrameworkInter-Thread CommunicationMultithreading Practice ProgramsRunnable InterfaceSynchronizationThread ClassMultithreading IntroductionThread Life CycleThread PriorityJava Cheat SheetImportant Formulas & Key ConceptsImportant Java ProgramsJava Quick RevisionAbstract ClassAbstractionAnonymous ClassClass and ObjectConstructorEncapsulationInheritanceInner ClassInterfaceMethod OverloadingMethod OverridingObject ClassObject CloningObject-Oriented Programming OOPPolymorphismstatic Keywordsuper Keywordthis KeywordWrapper ClassesArray Practice ProgramsBasic Java Practice ProgramsCollection Practice ProgramsJDBC Practice ProgramsMultithreading Practice ProgramsOOPs Practice ProgramsPlacement Coding QuestionsString Practice ProgramsBanking SystemChat ApplicationE-Commerce Backend — Spring Boot REST APIEmployee Management SystemLibrary Management SystemSpring Boot Fullstack ProjectStudent Management SystemCookies in ServletExpression Language ELGenericServletHttpServletJavaServer Pages JSPJSP TagsMVC ArchitectureHttpServletRequest & HttpServletResponseServlet IntroductionServlet Life CycleSession TrackingDependency InjectionSpring BeansSpring CoreSpring FrameworkAPI GatewaySpring Cloud Config ServerDocker DeploymentEureka Server — Service DiscoverySpring Boot CRUD ApplicationException Handling in Spring BootJWT AuthenticationREST API in Spring BootSpring SecuritySpring BootSpring Data JPAValidation in Spring Boot
Library Management System
Last Updated : 26 May, 2026
title: Library Management System
Projects65 words6 headingsExamples included
title: Library Management System description: Java aur JDBC se Library Management System
Books aur members ko manage karne ka console-based system.
Features
- Books add, search, update, delete karna
- Members register karna
- Books issue aur return karna
- Due date track karna
- Fine calculate karna
Technology Stack
- Java SE 17+
- JDBC
- MySQL
Database Setup
sql exampleWoHoTech
CREATE DATABASE library_db;
USE library_db;
CREATE TABLE books (
id INT PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(200) NOT NULL,
author VARCHAR(100),
isbn VARCHAR(20) UNIQUE,
category VARCHAR(50),
total_copies INT DEFAULT 1,
available_copies INT DEFAULT 1
);
CREATE TABLE members (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE,
phone VARCHAR(15),
membership_date DATE DEFAULT (CURRENT_DATE)
);
CREATE TABLE issued_books (
id INT PRIMARY KEY AUTO_INCREMENT,
book_id INT,
member_id INT,
issue_date DATE DEFAULT (CURRENT_DATE),
due_date DATE,
return_date DATE,
fine DOUBLE DEFAULT 0,
FOREIGN KEY (book_id) REFERENCES books(id),
FOREIGN KEY (member_id) REFERENCES members(id)
);Project Structure
library-management-system/
├── src/
│ ├── model/
│ │ ├── Book.java
│ │ ├── Member.java
│ │ └── IssuedBook.java
│ ├── dao/
│ │ ├── BookDAO.java
│ │ ├── MemberDAO.java
│ │ └── IssuedBookDAO.java
│ ├── service/
│ │ └── LibraryService.java
│ ├── util/
│ │ └── DBConnection.java
│ └── main/
│ └── Main.java
└── README.mdx
Book Model
package model;
public class Book {
private int id;
private String title;
private String author;
private String isbn;
private String category;
private int totalCopies;
private int availableCopies;
public Book() {}
public Book(String title, String author, String isbn, String category, int copies) {
this.title = title;
this.author = author;
this.isbn = isbn;
this.category = category;
this.totalCopies = copies;
this.availableCopies = copies;
}
// Getters aur Setters
public int getId() { return id; }
public void setId(int id) { this.id = id; }
public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; }
public String getAuthor() { return author; }
public void setAuthor(String author) { this.author = author; }
public String getIsbn() { return isbn; }
public void setIsbn(String isbn) { this.isbn = isbn; }
public String getCategory() { return category; }
public void setCategory(String category) { this.category = category; }
public int getTotalCopies() { return totalCopies; }
public void setTotalCopies(int totalCopies) { this.totalCopies = totalCopies; }
public int getAvailableCopies() { return availableCopies; }
public void setAvailableCopies(int availableCopies) { this.availableCopies = availableCopies; }
public boolean isAvailable() { return availableCopies > 0; }
@Override
public String toString() {
return String.format("[%d] %s by %s | ISBN: %s | Available: %d/%d",
id, title, author, isbn, availableCopies, totalCopies);
}
}
LibraryService — Issue aur Return
java exampleWoHoTech
package service;
import dao.*;
import model.*;
import java.time.LocalDate;
public class LibraryService {
private BookDAO bookDAO = new BookDAO();
private MemberDAO memberDAO = new MemberDAO();
private IssuedBookDAO issuedDAO = new IssuedBookDAO();
private static final int LOAN_DAYS = 14;
private static final double FINE_PER_DAY = 5.0;
public String issueBook(int bookId, int memberId) throws Exception {
Book book = bookDAO.findById(bookId).orElseThrow(() ->
new Exception("Book not found: " + bookId));
if (!book.isAvailable())
return "Book is not available currently";
memberDAO.findById(memberId).orElseThrow(() ->
new Exception("Member not found: " + memberId));
LocalDate issueDate = LocalDate.now();
LocalDate dueDate = issueDate.plusDays(LOAN_DAYS);
issuedDAO.insert(bookId, memberId, issueDate, dueDate);
bookDAO.decrementAvailable(bookId);
return "Book issued! Due date: " + dueDate;
}
public String returnBook(int issuedId) throws Exception {
IssuedBook issued = issuedDAO.findById(issuedId).orElseThrow(() ->
new Exception("Issue record not found"));
LocalDate returnDate = LocalDate.now();
double fine = 0;
if (returnDate.isAfter(issued.getDueDate())) {
long daysLate = returnDate.toEpochDay() - issued.getDueDate().toEpochDay();
fine = daysLate * FINE_PER_DAY;
}
issuedDAO.markReturned(issuedId, returnDate, fine);
bookDAO.incrementAvailable(issued.getBookId());
return fine > 0 ? "Book returned. Fine: Rs." + fine : "Book returned. No fine.";
}
}Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Library Management System.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Java topic.
Search Terms
java, java programming, core java, java master course, java notes, master, course, projects
Related Java Topics
Continue learning this concept
ProjectsEmployee Management Systemtitle: Employee Management SystemProjectsStudent Management Systemtitle: Student Management SystemProjectsBanking Systemtitle: Banking SystemProjectsChat Applicationtitle: Chat ApplicationProjectsE-Commerce Backend — Spring Boot REST APItitle: E-Commerce BackendProjectsSpring Boot Fullstack Projecttitle: Spring Boot Fullstack Project