Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vehicle Parking System

A Java Swing-based parking management system with MySQL database integration.

Features

  • Vehicle Entry Management: Record vehicle details (number, owner name, phone, type)
  • Vehicle Exit & Billing: Calculate parking fees based on duration and vehicle type
  • Real-time Statistics:
    • Available parking slots
    • Total revenue
    • Occupancy rate
  • Search Functionality: Filter parked vehicles by number or type
  • Parking Rates:
    • Motorcycle: Rs. 20/hour
    • Car: Rs. 50/hour
    • Van: Rs. 80/hour
    • Bus/Truck: Rs. 150/hour

Prerequisites

  1. Java Development Kit (JDK) - Version 8 or higher
  2. NetBeans IDE - Version 12 or higher (recommended)
  3. MySQL Server - Version 5.7 or higher
  4. MySQL Connector/J - JDBC driver for MySQL

Database Setup

Step 1: Install MySQL

  1. Download and install MySQL from mysql.com
  2. During installation, set the root password (or leave it empty for development)
  3. Start the MySQL service

Step 2: Create Database

  1. Open MySQL Command Line Client or MySQL Workbench

  2. Run the SQL script located at database_setup.sql:

    source C:/Users/Dilushan/Documents/NetBeansProjects/VehicleParkingSystem/database_setup.sql

    Or manually execute the commands in the file.

  3. Verify the database was created:

    SHOW DATABASES;
    USE parking_system;
    SHOW TABLES;

Project Setup in NetBeans

Step 1: Add MySQL Connector

  1. Download MySQL Connector/J from MySQL Downloads
  2. Extract the JAR file (e.g., mysql-connector-java-8.0.33.jar)
  3. In NetBeans:
    • Right-click on your project → Properties
    • Select LibrariesCompile tab
    • Click Add JAR/Folder
    • Browse and select the MySQL Connector JAR file
    • Click OK

Step 2: Configure Database Connection

The application connects to MySQL with these default settings:

  • Host: localhost
  • Port: 3306
  • Database: parking_system
  • Username: root
  • Password: (empty)

If your MySQL configuration is different, update the connection strings in cardContainer.java:

Connection conn = DriverManager.getConnection(
    "jdbc:mysql://localhost:3306/parking_system", 
    "root",  // Change username if needed
    ""       // Change password if needed
);

Running the Application

Option 1: Run from NetBeans

  1. Open the project in NetBeans
  2. Right-click on the project and select Run (F6)
  3. Or right-click on LoginForm.java and select Run File (Shift + F6)

Option 2: Run from Command Line

cd C:\Users\Dilushan\Documents\NetBeansProjects\VehicleParkingSystem\src
javac -cp ".;path\to\mysql-connector-java-X.jar" LoginForm.java
java -cp ".;path\to\mysql-connector-java-X.jar" LoginForm

Usage Guide

Parking a Vehicle

  1. Enter vehicle details:
    • Vehicle Number (required)
    • Owner Name (optional)
    • Phone Number (optional)
    • Vehicle Type (select from dropdown)
  2. Click Park button
  3. The vehicle will be added to the parked vehicles table

Exiting a Vehicle

  1. Select a vehicle from the table
  2. Click Exit button
  3. A receipt will be displayed showing:
    • Vehicle number
    • Parking duration (in hours)
    • Rate per hour
    • Total fee
  4. The vehicle status will be updated to "EXITED"

Searching Vehicles

  • Type in the search field to filter vehicles by number or type
  • The table updates automatically as you type

Troubleshooting

Common Issues

1. "No suitable driver found" error

  • Ensure MySQL Connector JAR is added to project libraries
  • Verify the JDBC URL format is correct

2. "Access denied for user" error

  • Check MySQL username and password in the code
  • Verify MySQL service is running

3. "Unknown database 'parking_system'" error

  • Run the database_setup.sql script
  • Verify database was created: SHOW DATABASES;

4. Table not displaying data

  • Check database connection
  • Verify data exists: SELECT * FROM parked_vehicles;
  • Check for exceptions in NetBeans output window

5. Spelling errors in UI

  • All spelling errors have been fixed in the latest version
  • If you see "Vehicala" or "Enty", rebuild the project

Project Structure

VehicleParkingSystem/
├── src/
│   ├── cardContainer.java    # Main parking management panel
│   └── mainFrame.java         # Main application frame
├── database_setup.sql         # Database creation script
├── mysql-connector-java-X.jar # MySQL JDBC driver
└── README.md                  # This file

Database Schema

parked_vehicles Table

Column Type Description
id INT (PK, AUTO_INCREMENT) Unique identifier
vehicle_number VARCHAR(20) Vehicle registration number
owner_name VARCHAR(100) Owner's name
phone VARCHAR(15) Contact number
vehicle_type VARCHAR(20) Type (Car, Motorcycle, Van, Bus, Truck)
entry_time TIMESTAMP Entry timestamp (auto-generated)
exit_time TIMESTAMP Exit timestamp (NULL if still parked)
parking_fee DECIMAL(10,2) Calculated fee
status ENUM 'PARKED' or 'EXITED'

Future Enhancements

  • User authentication system
  • Print receipt functionality
  • Daily/Monthly revenue reports
  • Configurable parking rates
  • SMS notifications
  • Barcode/QR code integration
  • Multi-floor parking support

License

This project is created for educational purposes.

Author

Dilushan

Support

For issues or questions, please check the troubleshooting section or contact the developer.

About

vehicle parking system java swing . databse connect

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages