A comprehensive Java Swing desktop application for managing bike rentals, built with MySQL database integration using JDBC. This application provides a complete solution for bike rental businesses with user management, inventory tracking, rental processing, and analytics.
- Features
- System Requirements
- Installation & Setup
- Project Structure
- How to Run
- Usage Guide
- Default Credentials
- Database Schema
- Screenshots
- Technologies Used
- Troubleshooting
- User Registration - Create new user accounts with validation
- Secure Login - Username/password authentication
- Role-based Access - Admin and regular user roles
- Profile Management - Update user information
- Add Bikes - Add new bikes to inventory
- Edit Bikes - Update bike details, rates, and maintenance status
- Delete Bikes - Remove bikes from inventory
- Track Availability - Real-time bike availability status
- Maintenance Tracking - Monitor bike condition
- Browse Available Bikes - View all bikes with details
- Rent Bikes - Select bike and duration with automatic cost calculation
- Return Bikes - Complete rentals and free up bikes
- Rental History - Track active and past rentals
- Total Rentals - Count of all completed rentals
- Revenue Tracking - Total earnings from rentals
- Bike Popularity - Ranking of most rented bikes
- Real-time Statistics - Live dashboard updates
- Gradient Backgrounds - Beautiful color schemes
- Responsive Tables - JTable with custom styling
- Interactive Forms - Input validation and error handling
- Card Layout Navigation - Smooth panel switching
- Custom Icons - Emoji-based visual indicators
- Java Development Kit (JDK) - Version 8 or higher
- MySQL Server - Version 5.7 or higher
- MySQL Connector/J (JDBC Driver) - Version 8.0 or compatible
- Operating System - Windows, macOS, or Linux
- RAM - Minimum 2GB recommended
- Screen Resolution - 1024x768 or higher
-
Install Java JDK
- Download from Oracle or use OpenJDK
- Set JAVA_HOME environment variable
- Verify installation:
java -version
-
Install MySQL Server
- Download from MySQL
- Install and configure (remember root password)
- Start MySQL service
-
Download MySQL Connector/J
- Download from MySQL Connector/J
- Extract the JAR file (e.g.,
mysql-connector-java-8.0.33.jar)
-
Open MySQL Command Line or MySQL Workbench
-
Run the database script:
mysql -u root -p < database.sqlOr manually execute the SQL file in MySQL Workbench.
-
Verify database creation:
USE rentamoto; SHOW TABLES;
-
Open
src/db/DBConnection.java -
Update database credentials:
private static final String URL = "jdbc:mysql://localhost:3306/rentamoto"; private static final String USERNAME = "root"; // Your MySQL username private static final String PASSWORD = ""; // Your MySQL password
-
Navigate to project directory:
cd "c:\Users\Hitesh\OneDrive\Desktop\New folder\Rentamoto1"
-
Compile all Java files:
javac -cp ".;mysql-connector-java-8.0.33.jar" -d bin src/Main.java src/db/*.java src/models/*.java src/services/*.java src/ui/*.java
Note: On Linux/Mac, use
:instead of;in classpath -
Run the application:
java -cp ".;bin;mysql-connector-java-8.0.33.jar" Main
- Import the project into your IDE
- Add MySQL Connector JAR to project libraries:
- Right-click project → Build Path → Add External JARs
- Select the
mysql-connector-java-x.x.xx.jarfile
- Run
Main.java
Rentamoto1/
│
├── src/
│ ├── Main.java # Application entry point
│ │
│ ├── db/
│ │ └── DBConnection.java # Database connection handler
│ │
│ ├── models/
│ │ ├── User.java # User entity class
│ │ ├── Bike.java # Bike entity class
│ │ └── Rental.java # Rental entity class
│ │
│ ├── services/
│ │ ├── UserService.java # User CRUD operations
│ │ ├── BikeService.java # Bike CRUD operations
│ │ └── RentalService.java # Rental CRUD operations
│ │
│ └── ui/
│ ├── LoginFrame.java # Login screen
│ ├── RegisterFrame.java # Registration screen
│ ├── Dashboard.java # Main dashboard
│ ├── BikeListPanel.java # View all bikes
│ ├── BikeManagementPanel.java # Admin bike management
│ ├── RentBikePanel.java # Rent bike interface
│ ├── ReturnBikePanel.java # Return bike interface
│ └── ReportsPanel.java # Analytics dashboard
│
└── database.sql # Database schema and sample data
- Ensure MySQL server is running
- Database 'rentamoto' is created (run
database.sql) - Update database credentials in
DBConnection.java - Add MySQL Connector JAR to classpath
- Compile and run
Main.java
The application will:
- Test database connection
- Display connection status in console
- Launch the login window
-
Register/Login
- Create account or login with credentials
- After login, access the dashboard
-
Browse Bikes
- Click "View Bikes" to see all available bikes
- View bike details, rates, and availability
-
Rent a Bike
- Click "Rent a Bike"
- Select bike from dropdown
- Choose rental hours (1-24)
- Confirm rental (cost calculated automatically)
-
Return a Bike
- Click "Return Bike"
- Select active rental from table
- Confirm return
All user features plus:
-
Manage Bikes
- Click "Manage Bikes"
- Add: Enter bike details and save
- Edit: Select bike, modify details
- Delete: Select bike and remove
-
View Reports
- Click "Reports"
- View total rentals and revenue
- Check bike popularity rankings
- Refresh data anytime
- Username:
admin - Password:
admin123 - Access: Full system access including reports and bike management
- Username:
john_doe| Password:pass123 - Username:
jane_smith| Password:pass123 - Username:
mike_wilson| Password:pass123
CREATE TABLE users (
id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) UNIQUE NOT NULL,
password VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
role ENUM('admin', 'user') DEFAULT 'user',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);CREATE TABLE bikes (
id INT PRIMARY KEY AUTO_INCREMENT,
model VARCHAR(100) NOT NULL,
rate_per_hour DECIMAL(10, 2) NOT NULL,
available BOOLEAN DEFAULT TRUE,
maintenance_status ENUM('good', 'needs_service', 'under_maintenance'),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);CREATE TABLE rentals (
id INT PRIMARY KEY AUTO_INCREMENT,
user_id INT NOT NULL,
bike_id INT NOT NULL,
hours INT NOT NULL,
total_cost DECIMAL(10, 2) NOT NULL,
status ENUM('active', 'completed') DEFAULT 'active',
rental_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
return_date TIMESTAMP NULL,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (bike_id) REFERENCES bikes(id)
);- Modern gradient background
- Clean authentication form
- Registration option
- Menu-based navigation
- Welcome screen with feature cards
- Role-based menu items
- JTable with bike details
- Color-coded availability
- Refresh functionality
- Dropdown bike selection
- Hour spinner (1-24 hours)
- Real-time cost calculation
- Statistics cards
- Bike popularity table
- Revenue tracking
- Java SE 8+ - Core programming language
- Java Swing - GUI framework
- JDBC (Java Database Connectivity) - Database interaction
- MySQL - Relational database
- OOP Principles - Encapsulation, inheritance, modularity
- MVC Pattern - Model-View separation
Problem: Application shows "Database connection failed" error
Solutions:
- Check MySQL service is running
- Verify database credentials in
DBConnection.java - Ensure
rentamotodatabase exists - Run
database.sqlto create tables - Check MySQL is listening on port 3306
Problem: JDBC driver not found
Solutions:
- Download MySQL Connector/J JAR
- Add JAR to project classpath
- For IDE: Add as external library
- For command line: Include in
-cpparameter
Problem: Cannot find symbol errors
Solutions:
- Ensure all source files are in correct packages
- Compile from root directory
- Use correct package structure
- Check Java version compatibility
Problem: Buttons or text appear cut off
Solutions:
- Update Java to latest version
- Try different Look and Feel in
Main.java - Increase screen resolution
- Check DPI scaling settings
Problem: Tables are empty after database setup
Solutions:
- Verify
database.sqlran successfully - Check sample data was inserted
- Refresh table using refresh button
- Check database connection
- Passwords are stored in plain text (for demonstration)
- In production, use password hashing (BCrypt, SHA-256)
- Implement SQL injection prevention with PreparedStatements (already done)
- Password encryption
- Email notifications
- Payment gateway integration
- Booking system with date/time
- User profile pictures
- Advanced search and filters
- Export reports to PDF/Excel
- Mobile app integration
- Modular design - Separated concerns (MVC-like)
- Reusable components - Service classes for CRUD
- Exception handling - Try-catch blocks throughout
- Input validation - Form validation and error messages
- Documentation - JavaDoc comments for classes/methods
- New Model: Create in
models/package - Database Operations: Create service in
services/ - UI Component: Create panel in
ui/ - Integration: Add to Dashboard menu
- Update
database.sql - Modify corresponding model class
- Update service methods
- Refresh UI components
This project is created for educational purposes. Free to use and modify.
For issues or questions:
- Check troubleshooting section
- Review code comments
- Verify database setup
- Check console output for errors
- Java JDK installed and configured
- MySQL Server installed and running
- MySQL Connector/J JAR downloaded
- Database created using
database.sql - Database credentials updated in
DBConnection.java - MySQL Connector JAR added to classpath
- All Java files compiled without errors
- Application runs and shows login screen
Happy Renting! 🚴♂️🚴♀️
RENTAMOTO - Making Bike Rentals Simple and Efficient