Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Local Student Management System

A Java-based client-server application for managing student records, courses, and enrollments over a local network using TCP socket programming. The server supports multiple concurrent client connections, with both an in-memory mode and a MySQL-backed persistent storage mode.


Table of Contents


Features

  • Student Management – Add, view, update, and delete student records
  • Course Management – Add and view courses
  • Enrollment System – Enroll students in courses with duplicate-enrollment prevention
  • Multi-Client Support – Thread-per-client model handles multiple connections simultaneously
  • Two Server Modes
    • In-memory (Server.java) – quick setup, no external dependencies
    • MySQL/XAMPP (Server_xamp.java) – persistent storage with a relational database
  • Real-Time Interaction – Console-based menu driven by server prompts

Architecture

┌──────────────────────┐          TCP/IP          ┌──────────────────┐
│  PC1 – Server        │        port 3334         │  PC2 – Client    │
│                      │◄────────────────────────►│                  │
│  Server.java         │   (multiple clients OK)  │  Client.java     │
│  or Server_xamp.java │                          │                  │
│                      │                          │  Console I/O     │
│  Data Storage:       │                          └──────────────────┘
│   • ArrayList (mem)  │                          ┌──────────────────┐
│   • MySQL (XAMPP)    │◄────────────────────────►│  PC3 – Client    │
└──────────────────────┘                          └──────────────────┘
  • Server listens on port 3334 and spawns a new thread for each client.
  • Clients connect over TCP, send menu choices, and receive results from the server.

Project Structure

Local-Student-Management-System/
├── PC1/                            # Server-side code
│   ├── Server.java                 # In-memory server implementation
│   ├── Server_xamp.java           # MySQL/XAMPP server implementation
│   ├── sms.sql                     # Database schema (SQL dump)
│   ├── readme.md                   # Quick server notes
│   └── Screenshot 2024-11-30 232208.png
├── PC2/                            # Client-side code
│   └── Client.java                 # Client application
├── icmpv4.png                      # ICMPv4 firewall configuration screenshot
├── LICENSE                         # MIT License
└── README.md                       # This file

Technologies Used

Category Details
Language Java 8+
Networking TCP sockets (java.net)
I/O java.io (BufferedReader, PrintWriter)
Database (optional) MySQL / MariaDB 10.4+ via JDBC
Database Tool XAMPP (phpMyAdmin)
IDE Eclipse or IntelliJ IDEA

Prerequisites

  • Java Development Kit (JDK) 8 or higher
  • Eclipse IDE or IntelliJ IDEA (or any Java IDE / command-line compiler)
  • Local network – all machines connected to the same LAN / router
  • (Optional, for MySQL mode) XAMPP with MySQL running on port 5222 and the MySQL Connector/J JAR on the classpath

Getting Started

Option A – In-Memory Server (PC1/Server.java)

No database setup is needed. Data is stored in memory and lost when the server stops.

  1. Open the project in your IDE on the server machine (PC1).
  2. Navigate to the SERVER package → Server.java.
  3. Run Server.java (in Eclipse: right-click → Run AsJava Application).
  4. The console will print:
    Server started on port 3334...
    

Option B – MySQL/XAMPP Server (PC1/Server_xamp.java)

Data is persisted in a MySQL database.

  1. Start XAMPP and make sure MySQL is running on port 5222.
  2. Create the sms database and import the schema (see Database Setup).
  3. Add the MySQL Connector/J JAR to your project's build path.
  4. Open Server_xamp.java in your IDE on PC1.
  5. Run Server_xamp.java. The console will print:
    Connected to the database successfully.
    Server started on port 3334...
    

Running the Client (PC2/Client.java)

  1. Open the project in your IDE on a client machine (PC2, PC3, …).
  2. In Client.java, update the server IP address to match PC1:
    Socket socket = new Socket("<SERVER_IP>", 3334); // e.g. "192.168.0.105"
  3. Run Client.java. The console will print:
    Connected to the PC1 (server) .
    
  4. Follow the on-screen menu to interact with the system.

Database Setup

Only required when using Server_xamp.java.

  1. Open phpMyAdmin (or the MySQL CLI).
  2. Create a new database called sms:
    CREATE DATABASE sms;
  3. Import the provided schema file:
    mysql -u root -P 5222 sms < PC1/sms.sql
    Or use phpMyAdmin's Import tab to upload PC1/sms.sql.

Schema

The sms database contains three tables:

students             courses              enrollments
+---------+---------+  +---------+---------+  +------------+-----------+
| id (PK) | name    |  | id (PK) | name    |  | student_id | course_id |
+---------+---------+  +---------+---------+  +------------+-----------+
                                               PK(student_id, course_id)
                                               FK → students(id)
                                               FK → courses(id)
  • students – stores student ID and name.
  • courses – stores course ID and name.
  • enrollments – junction table implementing a many-to-many relationship between students and courses, with foreign-key constraints for referential integrity.

Network Configuration

Finding the Server IP

OS Command
Windows ipconfig → look for IPv4 Address
Linux / macOS ifconfig or ip addr

Firewall – Open Port 3334

Make sure port 3334 is open on the server machine so that clients can connect.

  • Windows: Add an inbound rule in Windows Defender Firewall → Advanced Settings → Inbound Rules.
  • Linux: sudo ufw allow 3334/tcp && sudo ufw reload

Enabling ICMPv4 (Ping)

To verify connectivity between machines, enable ICMP (ping):

Enable ICMPv4 Example

Windows:

  1. Open Control Panel → System and Security → Windows Defender Firewall.
  2. Click Advanced Settings on the left sidebar.
  3. Select Inbound RulesNew Rule…
  4. Choose Custom → click Next.
  5. Under Protocol and Ports, select ICMPv4 → click Next.
  6. Allow the connection, finish the wizard, and name the rule (e.g., Enable ICMPv4).

Linux / macOS:

# Using ufw
sudo ufw allow icmp
sudo ufw reload

# Or using iptables
sudo iptables -A INPUT  -p icmp --icmp-type echo-request -j ACCEPT
sudo iptables -A OUTPUT -p icmp --icmp-type echo-reply   -j ACCEPT

Verify: ping <server_ip>


Usage

  1. Start the server on PC1 (either version).
  2. Connect one or more clients from other machines.
  3. Each client is presented with the interactive menu below.

Menu Reference

******** Student Management System ********

**** Developed By Md Mehedi Hasan ****
1. Add Student
2. View Students
3. Update Student
4. Delete Student
5. Add Course
6. View Courses
7. Enroll in Course
8. View Enrollments
9. Exit
Enter your choice:
Choice Action Prompts
1 Add Student Student ID, Student Name
2 View Students (none – lists all students)
3 Update Student Student ID, New Name
4 Delete Student Student ID
5 Add Course Course ID, Course Name
6 View Courses (none – lists all courses)
7 Enroll in Course Student ID, Course ID
8 View Enrollments (none – lists all enrollments)
9 Exit (disconnects from server)

Troubleshooting

Problem Possible Cause & Fix
Connection Refused Server is not running, or the IP/port in Client.java does not match the server. Verify the server is up and the address is correct.
Timeout Machines are not on the same network, or a firewall is blocking port 3334. Check network settings and firewall rules.
Database connection failed (MySQL mode only) XAMPP MySQL is not running on port 5222, or the sms database has not been created. Start MySQL and import sms.sql.
ClassNotFoundException (JDBC) The MySQL Connector/J JAR is not on the classpath. Add it to your IDE's build path.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a branch for your feature or bug fix:
    git checkout -b feature/my-new-feature
  3. Commit your changes with clear messages:
    git commit -m "Add: brief description of change"
  4. Push to your fork:
    git push origin feature/my-new-feature
  5. Open a Pull Request against main and describe your changes.

Please make sure your code compiles and runs correctly before submitting.


License

This project is licensed under the MIT License – see the LICENSE file for details.


Author

Md. Mehedi Hasan


Video Tutorials

About

A Java-based network application that leverages TCP/IP sockets to provide efficient management of students and courses across a network.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages