Skip to content

shubh100802/Library-Management-Java-and-SQL-

Repository files navigation

Library Management System

Modern desktop app to manage books, students, and lending workflows — built with Java Swing and MySQL.

Effortless adds, issues/returns with due dates and fines, quick availability checks, and one-click database backup/restore.

Table of Contents

Features

  • Add and view books and students
  • Issue and submit books with due dates and fine calculation
  • Search availability by code or title
  • Admin login and first-run DB initialization
  • Backup and restore the database from the UI

Requirements

  • Java JDK 8+ (JAVA_HOME set)
  • MySQL Server 8+ running locally on port 3306
  • MySQL Connector/J (provided: mysql-connector-j-8.0.33.jar)
  • Windows users: ensure mysqldump and mysql are on PATH for Backup/Restore

Quick Start

  1. Create the database schema

    • Start MySQL Server
    • Create schema: CREATE DATABASE library;
  2. (Option A) First run initializes tables automatically

    • The app creates required tables on startup if missing.

    (Option B) Initialize with SQL files

    • Base: mysql -u root -p library < lib.sql
    • Optional updates: mysql -u root -p library < update_library_schema.sql
  3. Build and run

javac -cp ".;mysql-connector-j-8.0.33.jar" *.java
java -cp ".;mysql-connector-j-8.0.33.jar" LibraryGUI

Tip (Windows): create run.bat:

@echo off
java -cp ".;mysql-connector-j-8.0.33.jar" LibraryGUI
pause

Configuration

Default database connection (see LibraryGUI.java):

  • URL: jdbc:mysql://localhost:3306/library
  • User: root
  • Password: Shubh@1008

You can change these in one place in LibraryGUI.java. Some panels currently open direct connections; for consistency, consider refactoring all panels to use LibraryGUI.getConnection().

Admin (GUI) credentials (from LoginPanel.java):

  • Username: admin
  • Password: Shubh1008

Security note: credentials are hardcoded for demo. For production, use environment variables or a config file and avoid exposing passwords on the command line (see Backup/Restore).

Project Structure

Library Management/
  AddBookPanel.java
  AddStudentPanel.java
  BackupPanel.java
  CheckAvailabilityPanel.java
  IssueBookPanel.java
  LibraryGUI.java
  LibraryManager.java  (optional CLI utility)
  LoginPanel.java
  MainMenuPanel.java
  SubmitBookPanel.java
  ViewBooksPanel.java
  ViewStudentsPanel.java
  lib.sql
  update_library_schema.sql
  mysql-connector-j-8.0.33.jar

Troubleshooting

  • Driver not found: com.mysql.cj.jdbc.Driver → ensure the connector jar is on the classpath
  • Access denied for user 'root'@'localhost' → verify the password or update DB_PASSWORD
  • Backup/Restore fails (exit code) → ensure MySQL bin is on PATH so mysqldump/mysql are found
  • Port conflicts → confirm MySQL is on 3306 or adjust DB_URL

Notes

  • This codebase uses simple JDBC without a connection pool. For production, consider pooling (e.g., HikariCP) and moving credentials to environment variables or a config file.
  • If distributing to multiple PCs, consider packaging with a small installer and bundling the JRE.

Made with ❤️ using Java, and MySQL.

About

A modern desktop app to manage books, students, and lending workflows. Features add/view, issue/return with fines, availability checks, and backup/restore.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages