A Java desktop application with CRUD functionality using Spring Core and JDBC Template for managing courier company records.
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
- Add New Courier - Create new courier records
- Display All Couriers - View all courier records in a formatted table
- Find Courier by ID - Search for specific courier by ID
- Update Courier - Modify existing courier information
- Delete Courier - Remove courier records with confirmation
- Find Couriers by Region - Filter couriers by their delivery region
- Display Total Couriers Count - Show total number of registered couriers
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)
- Java 8 or higher
- Maven 3.6+
- MySQL Server
- IDE (Eclipse, IntelliJ IDEA, etc.)
- Start your MySQL server
- Run the SQL script in
database_schema.sql
to create the database and table:mysql -u root -p < database_schema.sql
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" />
-
Navigate to the project directory
-
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
- 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
- ✅ 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
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