Skip to content

ashishraj1504/HotelManagementSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hotel Management System (Java + Swing + MySQL)

A desktop-based Hotel Management System built using Java Swing for the GUI and MySQL for data storage.
It helps manage common hotel operations like room management, employee management, drivers/pickup services, and reception tasks through an easy-to-use interface.


Tech Stack

  • Language: Java
  • UI: Java Swing / AWT
  • Database: MySQL
  • Database Connectivity: JDBC (MySQL Connector/J)
  • Table Rendering: net.proteanit.sql.DbUtils (used to show SQL ResultSet in JTable)

Features / Modules (Screens)

From the current codebase, the application includes modules like:

  • Login
  • Dashboard
  • Reception
  • Add Employee (Admin)
  • Add Rooms (Admin)
  • Add Drivers (Admin)
  • Rooms View (JTable data load)
  • Employee View / Manager Info
  • Departments View
  • Pickup Service (Driver lookup by car brand)

UI navigation is mainly done using Swing windows (JFrame) and menu actions.


Project Structure

HotelManagementSystem/
├── src/
│   └── HotelManagement/
│       ├── HotelManagementSystem.java   # Entry window (splash + Next -> Login)
│       ├── Login.java                   # Auth screen
│       ├── Dashboard.java               # Main dashboard + menus
│       ├── Conn.java                    # MySQL connection helper
│       └── ...                          # Other modules (Rooms, Employees, etc.)
└── README.md

Prerequisites

  • Java (JDK 8+ recommended)
  • MySQL Server (local)
  • MySQL JDBC Driver (Connector/J) available in your project classpath
  • (Optional) IDE like IntelliJ IDEA / Eclipse / NetBeans

Database Setup

1) Create database

CREATE DATABASE hms;
USE hms;

2) Create tables (example)

Your code queries tables like:

  • login
  • Room
  • Employee
  • Department
  • driver
create database hms; 
show databases;
use hms;
create table login( username varchar(40), password varchar(40) );
insert into login values('admin','12345'); 
select *  from Login;

create table employee(name varchar(25), age varchar(10), gender varchar(15), job varchar(30), phone varchar(15), aadhar varchar(40), email varchar(20));
describe employee;
select * from employee;

create table room(roomnumber varchar (10), availability varchar(20), cleaning_status varchar(20), price varchar(20), bed_type varchar(20));
select * from room;

create table driver(name varchar(20), age varchar(10), gender varchar(15), company varchar(20), branch varchar(20), available varchar(20), location varchar(40));
select * from driver;

create table customer(document varchar(20), number varchar(30), name varchar(30), gender varchar(15), country varchar(20), room varchar(10), checkintime varchar(80), deposit varchar(20));
select * from customer;

create table department(department varchar(30), budget varchar(30));
insert into department values ('Front Office','500000');
insert into department values ('Housekeeping','40000');
insert into department values ('Food and Beverage','23000');
insert into department values ('Kitchen or Food Production','540000');
insert into department values ('Security','320000');
select * from department;

Tip: Ensure table names match exactly what your code queries (case sensitivity may vary by OS/MySQL settings).


Configure DB Connection

The connection is currently created in src/HotelManagement/Conn.java.

Recommended (safer) approach

Instead of hardcoding credentials, use environment variables or a config file.

Example environment variables:

  • HMS_DB_URLjdbc:mysql://localhost:3306/hms
  • HMS_DB_USERroot
  • HMS_DB_PASSyour_password

If you want, I can also help you refactor Conn.java to load these securely.


How to Run

Option A: Run from an IDE

  1. Open the project in IntelliJ / Eclipse.
  2. Ensure JDBC driver is added to the classpath.
  3. Start MySQL server and verify the database exists.
  4. Run src/HotelManagement/HotelManagementSystem.java (main entry).

Option B: Run using terminal (basic)

If your classpath is set correctly:

javac -d out src/HotelManagement/*.java
java -cp out HotelManagement.HotelManagementSystem

If you use external libraries (like DbUtils, MySQL connector), you must add them to the -cp classpath.


Screens / UI Assets

The UI loads image assets like:

  • icons/first.jpg
  • icons/second.jpg
  • icons/third.jpg
  • etc.

Make sure the icons/ folder is available on the runtime classpath (commonly placed inside your project resources).


Known Issues / Notes

  • Hardcoded DB credentials inside the repo is unsafe.
  • Some SQL queries are built using string concatenation (can lead to SQL injection). PreparedStatements are recommended.
  • There is no Maven/Gradle build file currently; adding one would make setup much easier.

Future Improvements (Suggested)

  • Add Maven/Gradle build support
  • Use PreparedStatement everywhere
  • Implement role-based access (Admin vs Receptionist)
  • Add input validation and better error handling
  • Add export reports (PDF/Excel)
  • Add unit tests

Author

Ashish Raj
GitHub: ashishraj1504


License

This project is currently not licensed.
If you want it to be open-source, consider adding a MIT or Apache-2.0 license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages