This is a simple Java application that interacts with a relational database to manage employee data. It uses JDBC to perform CRUD (Create, Read, Update, Delete) operations on an employee table in the employee_db database. The application consists of an Employee entity class and an EmployeeData class for handling database operations.
- Create: Add new employees to the database.
- Read: Fetch details of a specific employee or list all employees.
- Update: Modify details of an existing employee.
- Delete: Remove an employee from the database.
- Java Development Kit (JDK): 8 or higher.
- Apache Maven: For dependency management.
- PostgreSQL Database: As the relational database system.
- PostgreSQL JDBC Driver: Added as a Maven dependency.
- Install and start PostgreSQL Server.
- Open a PostgreSQL client (e.g., pgAdmin or terminal).
- Create the
employee_dbdatabase:CREATE DATABASE employee_db;
- Connect to the
employee_dbdatabase:\c employee_db
- Create the
employeetable:CREATE TABLE employee ( id SERIAL PRIMARY KEY, name VARCHAR(100) NOT NULL, position VARCHAR(100) NOT NULL, salary DOUBLE PRECISION NOT NULL, hire_date DATE NOT NULL );
Clone the project repository from GitHub:
git clone https://github.com/your-username/employee-management-system.git
cd employee-management-systemUse Maven to build the project:
mvn clean installUpdate the database connection details in the EmployeeData class:
private static final String URL = "jdbc:postgresql://localhost:5432/employee_db";
private static final String USER = "postgres"; // Replace with your PostgreSQL username
private static final String PASSWORD = "yourpassword"; // Replace with your PostgreSQL passwordThe application will insert a new employee into the employee table.
Database State:
INSERT INTO employee (name, position, salary, hire_date)
VALUES ('Student AlaToo', 'HR Manager', 60000, '2023-01-15');SELECT * FROM employee WHERE id = 1;
UPDATE employee
SET salary = 65000
WHERE id = 1;
DELETE FROM employee WHERE id = 1;
employee-database-management-system
βββ src
β βββ main
β β βββ java
β β β βββ com.example
β β β βββ App.java # Main application
β β β βββ Employee.java # Employee entity class
β β β βββ EmployeeData.java # Database operations class
β βββ test
β βββ java
β βββ com.example
β βββ AppTest.java # Unit tests (optional)
βββ pom.xml # Maven configuration



