|
| 1 | +# Project DAO(Data Access Object) with JDBC in Java using MySQL |
| 2 | + |
| 3 | +This project is an implementation of the DAO (Data Access Object) pattern in Java, using JDBC (Java Database Connectivity) to interact with a MySQL database. The DAO pattern is an approach to organize the persistence layer in an application, separating data access operations from business logic. |
| 4 | + |
| 5 | +## About the Project |
| 6 | + |
| 7 | +The project consists of a simple management system for sellers and departments. It allows performing basic CRUD (Create, Read, Update, Delete) operations for sellers and departments, storing the data in a MySQL database. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +The project offers the following features: |
| 12 | + |
| 13 | +- Query seller by ID. |
| 14 | +- Query all sellers. |
| 15 | +- Query sellers by department. |
| 16 | +- Insert new seller. |
| 17 | +- Update seller data. |
| 18 | +- Delete a seller. |
| 19 | + |
| 20 | +## Project Structure |
| 21 | + |
| 22 | +The project is organized into packages, with the following structure: |
| 23 | + |
| 24 | +- `src`: Contains the packages and classes of the project. |
| 25 | + - `model.entities`: Contains the entity classes of the system. |
| 26 | + - `Department`: Represents the Department entity. |
| 27 | + - `Seller`: Represents the Seller entity. |
| 28 | + - `model.dao`: Contains the interfaces for the DAO classes. |
| 29 | + - `DepartmentDao`: Interface for the Department DAO. |
| 30 | + - `SellerDao`: Interface for the Seller DAO. |
| 31 | + - `model.dao.impl`: Contains the implementations of the DAO interfaces. |
| 32 | + - `DepartmentDaoJDBC`: Implementation of the Department DAO using JDBC. |
| 33 | + - `SellerDaoJDBC`: Implementation of the Seller DAO using JDBC. |
| 34 | + - `db`: Contains the classes related to the database connection. |
| 35 | + - `DB`: Utility class for configuring the database connection. |
| 36 | + - `DbException`: Custom exception for handling database errors. |
| 37 | + - `DaoFactory`: Class for instantiating DAOs. |
| 38 | + - `db.properties`: Configuration file with the database access information. |
| 39 | + - `Demo.java`: Demonstration class with examples of using the functionalities. |
| 40 | + |
| 41 | +## How to Use the Project |
| 42 | + |
| 43 | +1. Clone the project repository to your local environment. |
| 44 | +2. Configure the `db.properties` file with the access information to your MySQL database. |
| 45 | +3. Import the project into your preferred Java IDE (such as Eclipse or IntelliJ). |
| 46 | +4. Ensure that the dependencies are correctly configured (e.g., MySQLConnector). |
| 47 | + |
| 48 | +## Class Diagram |
| 49 | + |
| 50 | +<img src="https://github.com/jbrun0r/assets/blob/main/Java-DAO-JDBC/class-diagram.png?raw=true" width="100%"> |
| 51 | + |
| 52 | +## Overview of the DAO Pattern |
| 53 | + |
| 54 | +<img src="https://github.com/jbrun0r/assets/blob/main/Java-DAO-JDBC/data-access-object.png?raw=true" width="100%"> |
| 55 | + |
| 56 | +## Overview of JDBC |
| 57 | + |
| 58 | +<img src="https://github.com/jbrun0r/assets/blob/main/Java-DAO-JDBC/java-database-connectivity.png?raw=true" width="300px"> |
| 59 | + |
| 60 | +## References |
| 61 | + |
| 62 | +- [DevMedia - DAO Pattern: Data Persistence Using the DAO Pattern](https://www.devmedia.com.br/dao-pattern-persistencia-de-dados-utilizando-o-padrao-dao/30999) |
| 63 | +- [Oracle - Java Data Access Object](https://www.oracle.com/technetwork/java/dataaccessobject-138824.html) |
0 commit comments