Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

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

What you will learn

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

On your resume

Learn on Codify