This project now persists data to MySQL using JDBC. Follow the steps below to run it locally.
Run these commands in MySQL:
CREATE DATABASE IF NOT EXISTS car_reservation CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;Tables are auto-created on app start.
Download MySQL Connector/J (e.g., mysql-connector-j-8.x.x.jar). Place it in lib/ and include it on the classpath when compiling/running.
Example compile/run:
javac -cp lib/mysql-connector-j-8.4.0.jar -d bin src/essentials/*.java
java -cp bin;lib/mysql-connector-j-8.4.0.jar essentials.AppOn Unix/macOS replace ; with : in the classpath.
The app supports multiple configuration methods with priority order:
Create a .env file in your project root:
# Database Configuration
DB_URL=jdbc:mysql://localhost:3306/car_reservation?useSSL=false&serverTimezone=UTC
DB_USER=root
DB_PASS=your_password_here
# Optional: Database Name, Host, and Port
DB_NAME=car_reservation
DB_HOST=localhost
DB_PORT=3306Set these environment variables (overrides .env file):
Windows PowerShell:
$env:DB_URL = "jdbc:mysql://localhost:3306/car_reservation?useSSL=false&serverTimezone=UTC"
$env:DB_USER = "root"
$env:DB_PASS = "your_password"Windows Command Prompt:
set DB_URL=jdbc:mysql://localhost:3306/car_reservation?useSSL=false&serverTimezone=UTC
set DB_USER=root
set DB_PASS=your_passwordUnix/Linux/macOS:
export DB_URL="jdbc:mysql://localhost:3306/car_reservation?useSSL=false&serverTimezone=UTC"
export DB_USER="root"
export DB_PASS="your_password"If neither .env file nor environment variables are set, the app uses these defaults:
DB_URL:jdbc:mysql://localhost:3306/car_reservation?useSSL=false&serverTimezone=UTCDB_USER:rootDB_PASS:Harish_1234
App.main seeds three cars in the database at startup if they don't exist. You can adjust or remove that logic in src/essentials/App.java.
- Tables created:
cars(car_id, brand, model, base_price_per_day, is_available)customers(customer_id, name)rentals(id, car_id, customer_id, days, returned, created_at)
- The in-memory lists are kept for runtime operations but are synchronized with the database on writes.
- Configuration priority: Environment Variables > .env file > Default values =======
A simple Car Rental Management System built using Core Java (OOPs concepts).
This project allows customers to rent cars, manage rental data, and keep track of availability.
--
- Install Java JDK 17+
- Install Git (for cloning/pushing)
- Any IDE (VS Code, IntelliJ, Eclipse) or simple text editor
- Add and manage cars available for rent
- Register customers and their rental records
- Rent cars and track availability
- Demonstrates OOP concepts:
- Encapsulation (private fields + getters/setters)
- Inheritance (entities & system interaction)
- Polymorphism (method overriding/overloading)
- Abstraction (system-level design)
- Frontend interface using React.js
- REST API backend with Spring Boot