A JavaFX desktop application for room & booking management, built with Java 23, JavaFX 17, and a MySQL backend.
HospitalManagement is a JavaFX-based desktop client that lets staff log in and manage rooms and bookings through a graphical dashboard. The app uses FXML for its UI layouts, ControlsFX for enhanced JavaFX controls, and connects to a MySQL database through JDBC for persistence.
ℹ️ Note on naming: the repository is named
HospitalManagement, while the internal Maven artifact isProjectLabExamand the domain modeled in code is room/booking management (entitiesRoomandBooking, with ahoteldashboardscreen). The README below describes what the code actually does. Rename or retitle if you refactor the domain later.
- 🔐 Login screen — credentials checked against the database before granting access
- 🗂️ Main dashboard (
hoteldashboard.fxml) — overview and management of rooms - 👤 Staff dashboard (
staffdashboard.fxml) — staff-facing view with role-specific actions - 🛏️ Room management — add / view / manage rooms (
Roommodel) - 📅 Booking management — create and track bookings (
Bookingmodel) - 🎨 Styled UI — custom JavaFX styling via
style.css - 💾 MySQL persistence — JDBC connectivity handled by
DatabaseUtil
| Layer | Technology |
|---|---|
| Language | Java 23 |
| UI Framework | JavaFX 17 (FXML + CSS) |
| UI Extras | ControlsFX 11.2.1 |
| Database | MySQL (via mysql-connector-java 8.0.28 / JDBC) |
| Build Tool | Maven (with Maven Wrapper) |
| Testing | JUnit 5 (Jupiter) |
HospitalManagement/
├── src/main/
│ ├── java/com/example/projectlabexam/
│ │ ├── App.java # JavaFX application entry point
│ │ ├── LoginController.java # Login screen logic
│ │ ├── DashboardController.java # Main (hotel) dashboard logic
│ │ ├── StaffDashboardController.java # Staff dashboard logic
│ │ ├── Room.java # Room model/entity
│ │ ├── Booking.java # Booking model/entity
│ │ └── DatabaseUtil.java # MySQL connection & queries (JDBC)
│ └── resources/com/example/projectlabexam/
│ ├── login.fxml # Login layout
│ ├── hoteldashboard.fxml # Main dashboard layout
│ ├── staffdashboard.fxml # Staff dashboard layout
│ └── style.css # JavaFX styling
├── pom.xml # Maven build & dependencies
├── mvnw / mvnw.cmd # Maven wrapper
└── .mvn/wrapper/ # Maven wrapper config
- JDK 23 (or compatible — the POM targets Java 23)
- Maven (or use the included
mvnwwrapper — no local Maven install required) - MySQL server running locally (or a reachable remote instance)
git clone https://github.com/Gaston202/HospitalManagement.git
cd HospitalManagementCreate a database and the required tables for rooms, bookings, and users/staff. Example:
CREATE DATABASE hospital_management;
USE hospital_management;
-- Tables should match the fields used in Room.java, Booking.java,
-- and the login query in DatabaseUtil.java.
-- (Add your CREATE TABLE statements here based on the model classes.)📌 The exact schema depends on the columns referenced in
Room.java,Booking.java, and the login query inDatabaseUtil.java. Inspect those files to match table and column names.
Open src/main/java/com/example/projectlabexam/DatabaseUtil.java and set your MySQL credentials:
private static final String URL = "jdbc:mysql://localhost:3306/hospital_management";
private static final String USER = "your_mysql_user";
private static final String PASSWORD = "your_mysql_password";
⚠️ Security: avoid committing real credentials. Consider moving these values into a config file or environment variables and excluding them from version control.
Using the Maven wrapper:
./mvnw clean javafx:run # macOS / Linux
mvnw.cmd clean javafx:run # WindowsOr, if Maven is installed globally:
mvn clean javafx:runThe JavaFX login window will launch.
| Command | Description |
|---|---|
mvn clean javafx:run |
Build and launch the JavaFX desktop app |
mvn clean package |
Compile and package the app into a JAR |
mvn test |
Run JUnit 5 tests |
mvn clean |
Remove the target/ build directory |
App.javastarts the JavaFX application and loadslogin.fxml.LoginControllervalidates credentials against MySQL viaDatabaseUtil.- On success, the app routes to either the main dashboard (
hoteldashboard.fxml/DashboardController) or the staff dashboard (staffdashboard.fxml/StaffDashboardController). - From the dashboards, staff can manage Rooms and Bookings, with all data persisted to MySQL through
DatabaseUtil.
- Externalize DB credentials into a config file / environment variables
- Add password hashing for staff login
- CRUD UI for rooms and bookings (add / edit / delete forms)
- Search & filter bookings by date or status
- Input validation and user-friendly error dialogs (ControlsFX)
- Unit tests for
DatabaseUtil,Room, andBooking
This is a personal/learning project, but contributions are welcome.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open-source and available under the MIT License.
Gaston — GitHub @Gaston202
Built as a lab/exam project to practice Java, JavaFX, JDBC, and MySQL.