A simple Fuel Management System built with Java and MySQL for managing fuel types, quantities, and transactions. This project demonstrates basic CRUD operations with database connectivity using JDBC.
- Registration and Login system with role-based access (User/Admin).
- Password storage with basic security measures.
- Admins can create, update, delete, and manage events.
- View a list of events with relevant details such as date, location, and organizer.
- Admins can generate event reports in real-time.
- Fully responsive and interactive UI using HTML, CSS, and JavaScript.
- MySQL database integration to store and retrieve user and event data securely.
- Easily extendable to include additional features like ticket management or notifications.
Before you can run the project, make sure you have the following installed:
- Java Development Kit (JDK): Version 8 or higher (This project uses JDK 23).
- IntelliJ IDEA: (or any Java-compatible IDE).
- MySQL Database: Make sure MySQL is installed and running on your system.
- MySQL Connector/J: The JDBC driver for MySQL.
- **Maven: For dependency management and project build.
The project is organized as follows:
FuelManagementSystem/
├── src/
│ ├── main/
│ │ ├── dao/ # Data Access Objects
│ │ │ ├── FuelDAO.java # DAO for fuel management
│ │ │ ├── TransactionDAO.java # DAO for transaction management
│ │ │ └── UserDAO.java # DAO for user management
│ │ ├── model/ # Data models
│ │ │ ├── Fuel.java # Fuel entity
│ │ │ ├── Transaction.java # Transaction entity
│ │ │ └── User.java # User entity
│ │ ├── service/ # Service layer
│ │ │ ├── FuelService.java # Business logic for fuel operations
│ │ │ ├── TransactionService.java # Business logic for transactions
│ │ │ └── UserService.java # Business logic for user operations
│ │ ├── util/ # Utility classes
│ │ │ └── DBConnection.java # Database connection utility
│ │ ├── web/ # Web controllers
│ │ │ ├── UserServlet.java # Servlet for user operations
│ │ │ ├── FuelServlet.java # Servlet for fuel operations
│ │ │ ├── TransactionServlet.java # Servlet for transaction operations
│ │ └── Main.java # Console-based application entry point
├── src/test/ # Unit tests
│ ├── dao/ # Tests for DAO classes
│ │ ├── FuelDAOTest.java # FuelDAO tests
│ │ ├── TransactionDAOTest.java # TransactionDAO tests
│ │ └── UserDAOTest.java # UserDAO tests
│ ├── service/ # Tests for service classes
│ │ ├── FuelServiceTest.java # FuelService tests
│ │ ├── TransactionServiceTest.java # TransactionService tests
│ │ └── UserServiceTest.java # UserService tests
├── src/main/webapp/ # Web resources
│ ├── WEB-INF/ # Deployment descriptor and config
│ │ └── web.xml # Servlet mappings and security
│ ├── jsp/ # JSP pages
│ │ ├── fuel-records.jsp # Records the Data
│ │ ├── report.jsp # Report Area
│ │ └── setting.jsp # Setting the type of Data
│ │── js/ # Java Script Page
| | |__ script.js # Java Script
│ ├── css/ # Stylesheets
│ │ └── styles.css # Styling for web pages
│ |── index.jsp # Home page
| ├── fuel-records.html/ # Page to view and manage fuel records
| ├── index.html/ # Home page(Main page to start website)
| ├── reports.html/ # Reports page for analytics
| ├── settings.html/ # Settings page
| |__ images/ # Images used in the web application
├── lib/ # External libraries
│ └── mysql-connector-java-x.x.x.jar # MySQL JDBC driver
├── db/ # Database scripts
│ ├── fuel_management_db.sql # Script for fuel tables
│ └── user_management_db.sql # Script for user tables
├── docs/ # Documentation
│ ├── API_Documentation.md # API reference
│ ├── Project_Report.md # Final project report
│ └── User_Manual.md # User instructions
├── pom.xml # Maven configuration
├── README.md # Project overview and instructions
└── reviews/ # Review notes and resolutions
└── review_comments.md # Review feedback
dao/
: Contains classes for database operations.model/
: Contains Java classes representing theFuel
andTransaction
tables.util/
: Contains utility classes such asDBConnection
for managing database connections.db/
: Contains SQL script to set up the MySQL database and tables.
Follow these steps to set up and run the project:
- Clone the repository or download the project files.
Open your IDE (IntelliJ IDEA, Eclipse, or VS Code). Import the project as a Maven Project. Ensure the pom.xml file is loaded to download necessary dependencies.
-
Open MySQL Workbench or MySQL Command Line.
-
Run the SQL script located at
db/fuel_management_db.sql
to create the necessary database and tables.-- Use this SQL script to set up the database CREATE DATABASE IF NOT EXISTS FuelManagementDB; USE FuelManagementDB; CREATE TABLE IF NOT EXISTS Fuel ( fuel_id INT AUTO_INCREMENT PRIMARY KEY, type VARCHAR(50) NOT NULL, quantity DOUBLE NOT NULL ); CREATE TABLE IF NOT EXISTS Transaction ( transaction_id INT AUTO_INCREMENT PRIMARY KEY, fuel_id INT, transaction_type ENUM('purchase', 'sale', 'refill') NOT NULL, amount DOUBLE NOT NULL, transaction_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (fuel_id) REFERENCES Fuel(fuel_id) );
-
Note: Make sure to update the MySQL username and password in the
DBConnection.java
file to match your MySQL setup.
-
Open
src/util/DBConnection.java
and update the following lines with your MySQL credentials:private static final String URL = "jdbc:mysql://localhost:3306/FuelManagementDB"; private static final String USER = "your_username"; private static final String PASSWORD = "your_password";
- Download the MySQL Connector/J
.jar
file from MySQL's official site. - Place the
.jar
file in thelib/
folder. - In IntelliJ, right-click the
.jar
file and selectAdd as Library
to include it in your project dependencies.
- Open IntelliJ IDEA.
- Open the project folder in IntelliJ.
- Set the JDK version:
- Go to
File > Project Structure > Project
, and set the SDK to the version of Java you have installed (JDK 23 is recommended).
- Go to
- Compile and Run:
- Right-click on
Main.java
(located insrc/main/
) and selectRun 'Main'
.
- Right-click on
Once the project is running, you will see a console-based menu for the Fuel Management System. Here are the options available:
- Add Fuel: Allows you to add a new fuel type and quantity.
- View All Fuels: Displays all fuel types and their quantities.
- Add Transaction: Records a transaction for a fuel type (purchase, sale, or refill).
- View All Transactions: Displays all transaction history.
- Exit: Exits the application.
- Add Fuel: When prompted, enter the type of fuel (e.g., Diesel) and the quantity.
- Add Transaction: Enter the fuel ID, transaction type (purchase, sale, or refill), and the amount.
- View Transactions: Shows a list of all transactions.
-
Database Connection Error:
- Ensure MySQL is running, and the
DBConnection
class has the correct username, password, and database URL.
- Ensure MySQL is running, and the
-
MySQL Connector Error:
- If IntelliJ cannot find the MySQL Connector/J, ensure that it is added as a library in your project.
-
Table Not Found Error:
- Make sure you have run the SQL script
fuel_management_db.sql
to create the tables in MySQL.
- Make sure you have run the SQL script
This guide should help you get up and running with the Fuel Management System project. For any further issues, please consult the error messages or documentation for IntelliJ and MySQL.