Skip to content

arjungautam1/Springapp-javaassignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Courier Management System

A Java desktop application with CRUD functionality using Spring Core and JDBC Template for managing courier company records.

Project Structure

springapp/
├── src/main/java/com/arjun/springapp/
│   ├── App.java                    # Main application class
│   ├── controller/
│   │   └── CourierController.java  # Controller for user input handling
│   ├── dao/
│   │   └── CourierDAO.java         # Data Access Object for database operations
│   └── model/
│       └── Courier.java            # Model class with courier fields
├── src/main/resources/
│   └── applicationContext.xml      # Spring XML configuration
├── database_schema.sql             # Database creation script
└── pom.xml                        # Maven dependencies

Features

  1. Add New Courier - Create new courier records
  2. Display All Couriers - View all courier records in a formatted table
  3. Find Courier by ID - Search for specific courier by ID
  4. Update Courier - Modify existing courier information
  5. Delete Courier - Remove courier records with confirmation
  6. Find Couriers by Region - Filter couriers by their delivery region
  7. Display Total Couriers Count - Show total number of registered couriers

Database Schema

The application uses a MySQL database named Couriers with the following structure:

Courier Table:

  • Courier_id (INT, PRIMARY KEY, AUTO_INCREMENT)
  • Name (VARCHAR(100), NOT NULL)
  • Contact (VARCHAR(20), NOT NULL)
  • Region (VARCHAR(100), NOT NULL)
  • ItemsDelivered (INT, DEFAULT 0)
  • VisitDate (DATE, NOT NULL)
  • hours (DECIMAL(5,2), NOT NULL)

Setup Instructions

Prerequisites

  • Java 8 or higher
  • Maven 3.6+
  • MySQL Server
  • IDE (Eclipse, IntelliJ IDEA, etc.)

Database Setup

  1. Start your MySQL server
  2. Run the SQL script in database_schema.sql to create the database and table:
    mysql -u root -p < database_schema.sql

Configuration

Update the database connection details in src/main/resources/applicationContext.xml:

<property name="url" value="jdbc:mysql://localhost:3306/Couriers?useSSL=false&serverTimezone=UTC" />
<property name="username" value="root" />
<property name="password" value="your_password" />

Running the Application

  1. Navigate to the project directory

  2. Compile and run using Maven:

    mvn clean compile exec:java -Dexec.mainClass="com.arjun.springapp.App"

    Or run directly:

    mvn clean compile
    java -cp "target/classes:target/dependency/*" com.arjun.springapp.App

Technologies Used

  • Spring Core 5.3.23 - Dependency injection and IoC container
  • Spring JDBC 5.3.23 - Database operations with JdbcTemplate
  • MySQL Connector 8.0.33 - Database connectivity
  • Maven - Dependency management and build tool

Assignment Requirements Fulfilled

  • ✅ Created database named Couriers
  • ✅ Created table named Courier in the database
  • ✅ Created Controller class for taking user input
  • ✅ Added Maven dependencies for Spring Core and JDBC
  • ✅ Created Courier Java class as Model
  • ✅ Created separate DAO class for database operations
  • ✅ Created separate XML config file for connection and data source
  • ✅ Created main application class to display data on console

Usage Example

When you run the application, you'll see a menu with options:

========== Courier Management System ==========
1. Add New Courier
2. Display All Couriers
3. Find Courier by ID
4. Update Courier
5. Delete Courier
6. Find Couriers by Region
7. Display Total Couriers Count
8. Exit
Enter your choice:

Select an option by entering the corresponding number and follow the prompts.# Springapp-javaassignment

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages