Projects › Beginner
Student Management System
A console (or Swing) app to add, search, update and delete students and their marks, stored in MySQL.
Level: Beginner · Time: 4–6 days · Tech stack: Java, JDBC, MySQL
Features to build
- CRUD for students: roll no, name, branch, marks
- Search by name/branch, sort by marks
- Report: topper, average, pass percentage
- Input validation
- Data stored in MySQL via JDBC
What you will learn
- OOP: classes and encapsulation
- Collections
- JDBC and PreparedStatement
- SQL CRUD and aggregate queries
Step-by-step guide
1. Design the classes
Student (fields + getters), StudentDao (database code), Main (menu). Keeping DB code in a DAO is how real projects are layered.
2. Create the table
CREATE TABLE students (roll INT PRIMARY KEY, name VARCHAR(60) NOT NULL, branch VARCHAR(20), marks DECIMAL(5,2));
3. Connect with JDBC
Add the MySQL connector JAR (or Maven dependency mysql-connector-j).
try (Connection c = DriverManager.getConnection(URL, USER, PASS);
PreparedStatement ps = c.prepareStatement("INSERT INTO students VALUES (?, ?, ?, ?)")) {
ps.setInt(1, s.getRoll()); ps.setString(2, s.getName());
ps.setString(3, s.getBranch()); ps.setDouble(4, s.getMarks());
ps.executeUpdate();
}
Always use PreparedStatement — string concatenation allows SQL injection.
4. The menu
A while (true) loop with Scanner: 1 Add, 2 View all, 3 Search, 4 Update, 5 Delete, 6 Report, 0 Exit. Catch InputMismatchException for bad input.
5. Reports with SQL
SELECT AVG(marks), MAX(marks), SUM(marks >= 40) * 100 / COUNT(*) FROM students — let the database do the maths.
6. Level it up to a GUI
Use Swing (JTable for the list) or JavaFX once the console version works.
Level it up
- Convert it into a Spring Boot REST API
- Add login for teachers
- Export reports to PDF
On your resume
- Developed a Java student management system with JDBC and MySQL supporting CRUD, search, sorting and aggregate reports using prepared statements.