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.
- Features
- Architecture
- Project Structure
- Technologies Used
- Prerequisites
- Getting Started
- Database Setup
- Network Configuration
- Usage
- Troubleshooting
- Contributing
- License
- Author
- Video Tutorials
- 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
- In-memory (
- Real-Time Interaction – Console-based menu driven by server prompts
┌──────────────────────┐ 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.
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
| 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 |
- 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
No database setup is needed. Data is stored in memory and lost when the server stops.
- Open the project in your IDE on the server machine (PC1).
- Navigate to the
SERVERpackage →Server.java. - Run
Server.java(in Eclipse: right-click → Run As → Java Application). - The console will print:
Server started on port 3334...
Data is persisted in a MySQL database.
- Start XAMPP and make sure MySQL is running on port 5222.
- Create the
smsdatabase and import the schema (see Database Setup). - Add the MySQL Connector/J JAR to your project's build path.
- Open
Server_xamp.javain your IDE on PC1. - Run
Server_xamp.java. The console will print:Connected to the database successfully. Server started on port 3334...
- Open the project in your IDE on a client machine (PC2, PC3, …).
- In
Client.java, update the server IP address to match PC1:Socket socket = new Socket("<SERVER_IP>", 3334); // e.g. "192.168.0.105"
- Run
Client.java. The console will print:Connected to the PC1 (server) . - Follow the on-screen menu to interact with the system.
Only required when using
Server_xamp.java.
- Open phpMyAdmin (or the MySQL CLI).
- Create a new database called
sms:CREATE DATABASE sms;
- Import the provided schema file:
Or use phpMyAdmin's Import tab to upload
mysql -u root -P 5222 sms < PC1/sms.sqlPC1/sms.sql.
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.
| OS | Command |
|---|---|
| Windows | ipconfig → look for IPv4 Address |
| Linux / macOS | ifconfig or ip addr |
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
To verify connectivity between machines, enable ICMP (ping):
Windows:
- Open Control Panel → System and Security → Windows Defender Firewall.
- Click Advanced Settings on the left sidebar.
- Select Inbound Rules → New Rule…
- Choose Custom → click Next.
- Under Protocol and Ports, select ICMPv4 → click Next.
- 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 ACCEPTVerify: ping <server_ip>
- Start the server on PC1 (either version).
- Connect one or more clients from other machines.
- Each client is presented with the interactive menu below.
******** 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) |
| 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. |
Contributions are welcome! To contribute:
- Fork the repository.
- Create a branch for your feature or bug fix:
git checkout -b feature/my-new-feature
- Commit your changes with clear messages:
git commit -m "Add: brief description of change" - Push to your fork:
git push origin feature/my-new-feature
- Open a Pull Request against
mainand describe your changes.
Please make sure your code compiles and runs correctly before submitting.
This project is licensed under the MIT License – see the LICENSE file for details.
Md. Mehedi Hasan
