An inventory management system in Java using JDBC and MySQL.
This console-based inventory system provides a simple and organized way to manage products, now with database persistence using MySQL.
It allows users to:
- Add, list, update, and remove products
- Manage product quantities efficiently
- Persist data using a MySQL database
- Validate user input to prevent errors
- Maintain a clean and modular layered architecture
The project is organized into packages for clarity and maintainability:
-
model
Contains theProductclass (attributes, constructors, getters/setters,toString) -
repository
ContainsProductRepository, responsible for database access (CRUD operations using JDBC) -
service
ContainsInventoryService, which handles business logic and validations -
utils
Contains helper classes likeInputUtils(safe user input handling) -
configContains database-related classes:MySQLConnectionExample(example of JDBC connection)ConnectionTest(used to test database connectivity)
-
resources
Containsdatabase.sql, the SQL script used to create the database schema -
Main.java
Main class that runs the interactive console menu
This project uses a MySQL database.
To create the database and tables:
- Open MySQL Workbench (or another MySQL client)
- Execute the SQL script located at:
resources/database.sql
This script will create:
- The
inventory_dbdatabase - The
productstable with appropriate constraints (UNSIGNED,DECIMAL, etc.)
You must configure your own database connection locally by providing:
- Database URL
- Username
- Password
Each user must create and configure their own MySQL database and update the connection settings accordingly in the MySQLConnectionExample class, located in the config package.
- Clone the repository:
git clone <your-repo-url>