To start a Java database project, install MySQL, create a small schema (students, subjects, marks), add a JDBC driver to your Java project, and run parameterised queries from a plain Java class. You can finish a working version in a few evenings, and a 14-day plan below shows how to spread it out and make it portfolio-ready.
This guide is written for students of Jai Prakash Vishwavidyalaya, Chapra, but the technical steps apply to any laptop. It uses a student-marks database because every student understands the data, and it exercises the skills employers expect from a junior Java developer: schema design, JDBC, joins, indexes, backups and safe handling of data.
What you will build and what you need installed
The project is a console application that stores students, subjects and marks, then answers questions such as “What is the average mark in each subject?” and “Who scored below the pass mark in Java?”. No web framework is needed. Keeping it plain JDBC means you understand what frameworks later do for you.
- JDK 17 or newer (any current LTS release works).
- MySQL Community Server 8.x and MySQL Workbench, or the command-line client.
- MySQL Connector/J, the official JDBC driver. Use Maven or Gradle to fetch it, or download the JAR manually.
- An IDE such as IntelliJ IDEA Community, Eclipse or VS Code with Java extensions.
- Git, so your project history is visible later.
Designing the student-marks schema before writing any Java
Three tables are enough. Separating students, subjects and marks avoids repeating a student’s name on every row and lets you practise foreign keys and joins.
| Table | Key columns | Purpose |
|---|---|---|
| students | student_id (PK), roll_no (unique), full_name, programme, admission_year | One row per student |
| subjects | subject_id (PK), subject_code (unique), subject_name, max_marks | One row per subject |
| marks | mark_id (PK), student_id (FK), subject_id (FK), semester, marks_obtained | One row per student per subject per semester |
Run this in MySQL Workbench or the command-line client. The SQL is an illustrative starting point; adjust the names to your taste.
CREATE DATABASE marks_db CHARACTER SET utf8mb4;
USE marks_db;
CREATE TABLE students (
student_id INT AUTO_INCREMENT PRIMARY KEY,
roll_no VARCHAR(20) NOT NULL UNIQUE,
full_name VARCHAR(100) NOT NULL,
programme VARCHAR(60),
admission_year SMALLINT
);
CREATE TABLE subjects (
subject_id INT AUTO_INCREMENT PRIMARY KEY,
subject_code VARCHAR(20) NOT NULL UNIQUE,
subject_name VARCHAR(100) NOT NULL,
max_marks SMALLINT NOT NULL DEFAULT 100
);
CREATE TABLE marks (
mark_id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT NOT NULL,
subject_id INT NOT NULL,
semester TINYINT NOT NULL,
marks_obtained DECIMAL(5,2) NOT NULL,
CONSTRAINT fk_marks_student FOREIGN KEY (student_id) REFERENCES students(student_id),
CONSTRAINT fk_marks_subject FOREIGN KEY (subject_id) REFERENCES subjects(subject_id),
CONSTRAINT uq_student_subject_sem UNIQUE (student_id, subject_id, semester)
);
The unique constraint on (student_id, subject_id, semester) stops the same result from being entered twice, a bug that otherwise surfaces late in testing.
Free 2-Week CareerSwami Internship
Online, 14 days, with a free offer letter and a free completion certificate once you finish the work. Check with your college that it fits your requirement before you enrol.
Creating a separate MySQL user for your Java application
Do not connect from Java as root. Create a user that can only touch this one database.
CREATE USER 'marks_app'@'localhost' IDENTIFIED BY 'choose-a-strong-password';
GRANT SELECT, INSERT, UPDATE, DELETE ON marks_db.* TO 'marks_app'@'localhost';
This habit is small but matters: if a bug or injection flaw appears, the damage is limited to one schema and cannot drop the database or touch others.
Connecting Java to MySQL with JDBC, step by step
- Create a Maven project and add the connector dependency (
com.mysql:mysql-connector-j) topom.xml. Check Maven Central for the current version number. - Keep credentials out of source code. Read the URL, user and password from environment variables or a properties file listed in
.gitignore. - Open the connection with
DriverManager.getConnectioninside a try-with-resources block so it closes automatically. - Use PreparedStatement for every query that includes a value.
- Handle SQLException by logging a useful message, not by printing the password or full connection string.
An illustrative connection class (not run here; test it on your own machine):
import java.sql.*;
public class Db {
public static Connection open() throws SQLException {
String url = System.getenv("MARKS_DB_URL"); // e.g. jdbc:mysql://localhost:3306/marks_db
String user = System.getenv("MARKS_DB_USER");
String pass = System.getenv("MARKS_DB_PASS");
return DriverManager.getConnection(url, user, pass);
}
}
Inserting and querying marks with parameterised statements
Adding a mark should never be done by joining strings together. A PreparedStatement sends the SQL and values separately, which blocks SQL injection and handles quotes in names correctly.
String sql = "INSERT INTO marks (student_id, subject_id, semester, marks_obtained) VALUES (?, ?, ?, ?)";
try (Connection c = Db.open();
PreparedStatement ps = c.prepareStatement(sql)) {
ps.setInt(1, studentId);
ps.setInt(2, subjectId);
ps.setInt(3, semester);
ps.setBigDecimal(4, new java.math.BigDecimal("72.50"));
ps.executeUpdate();
}
A reporting query that joins all three tables:
SELECT s.roll_no, s.full_name, sub.subject_name, m.marks_obtained
FROM marks m
JOIN students s ON s.student_id = m.student_id
JOIN subjects sub ON sub.subject_id = m.subject_id
WHERE m.semester = ? AND sub.subject_code = ?
ORDER BY m.marks_obtained DESC;
Read the result with a ResultSet loop, using column names rather than positions so a later schema change does not silently break your code.
Wrapping multi-row updates in a transaction
When you load a whole class’s marks at once, turn off auto-commit, insert all rows, and commit only if everything succeeds. Call rollback() in the catch block. Otherwise one bad row leaves half a class saved and half missing.
Worked illustrative example: finding students below the pass mark
Suppose your test data has three students and one subject, “Java Programming” (JAVA101, max 100). This is made-up data for practice.
| roll_no | full_name | Semester | marks_obtained |
|---|---|---|---|
| T-001 | Test Student A | 3 | 78.00 |
| T-002 | Test Student B | 3 | 34.50 |
| T-003 | Test Student C | 3 | 41.00 |
You want everyone below 40% in JAVA101. Because max_marks may differ by subject, compute the percentage in SQL instead of hard-coding 40:
SELECT s.roll_no, m.marks_obtained,
ROUND(m.marks_obtained / sub.max_marks * 100, 1) AS pct
FROM marks m
JOIN students s ON s.student_id = m.student_id
JOIN subjects sub ON sub.subject_id = m.subject_id
WHERE sub.subject_code = ?
AND m.marks_obtained / sub.max_marks < 0.40;
With the sample rows above, the expected result is only T-002 (34.5%). Write that expectation down first, run the query, and compare. Checking against a result you worked out by hand is the simplest form of testing a database query. Then add a boundary row at exactly 40.00 to confirm the comparison treats it as a pass.
Checklist for indexing, backups and safe test data
Use this before you call the project finished or show it to anyone.
| Area | Check | How to verify |
|---|---|---|
| Indexing | Primary and unique keys exist on roll_no, subject_code and the (student, subject, semester) combination | Run SHOW INDEX FROM marks; |
| Indexing | Columns used often in WHERE or JOIN (for example marks.subject_id and marks.semester) are indexed | Run EXPLAIN on your report query and look at the access type and key used |
| Indexing | No index added “just in case” on every column | Each extra index slows inserts; keep only those a query uses |
| Backups | A logical backup with mysqldump exists | Run mysqldump -u marks_app -p marks_db > marks_db_backup.sql |
| Backups | You have actually restored a backup into a scratch database | Create marks_db_test, import the file, compare row counts |
| Backups | Backup file is stored away from the project folder and not committed to Git | Check .gitignore and git status |
| Test data | Only invented names and roll numbers (for example T-001) are used | Scan the tables for any real person’s details |
| Test data | Real marks, Aadhaar numbers, phone numbers or enrolment details are never loaded | Review your seed script before sharing the repository |
| Test data | Seed script is repeatable | Run it twice on a fresh database and get identical counts |
| Security | Application uses the limited user, not root, and password is not in code | Search the repository for the password string |
Reading an EXPLAIN result without guessing
If EXPLAIN shows type: ALL, MySQL is scanning the whole table. On a class-sized dataset this is harmless, but it is worth learning to spot. Insert a few thousand generated test rows, add an index on marks(subject_id, semester), and run EXPLAIN again. Note the change in your project README as evidence of what you learned.
Jai Prakash University students: using a database project alongside your coursework
The university’s own website describes it as Jai Prakash University, Chapra, established in 1990, and its homepage notices mention UG-CBCS and PG-CBCS programmes as well as an NEP PG syllabus implemented from session 2026-28. In practice, this means your programme’s structure may differ depending on your batch, so do not assume a Java or database course sits in your semester plan. This article has not verified which computing programmes or papers exist; check your own syllabus.
The Training & Placement Cell page describes the cell as a link between students and employers and lists working with organisations that offer hands-on experience through summer internships and projects. The page does not state internship rules, credits or duration, so treat a self-built project as personal skill-building unless your department tells you otherwise in writing.
The site menu also has separate Constituent Colleges and Affiliated Colleges pages, so rules may be set by the university or by your college. Confirm which applies to you.
Verification steps:
- Open your programme’s current syllabus from the university website or your department office and check whether Java, DBMS or SQL papers appear, and in which semester.
- Ask your department in writing whether a self-made project or online internship can be mentioned in a project report, and what documents they would need.
- Email or visit the Training & Placement Cell and ask whether it accepts external internship certificates and what format it prefers.
- Ask whether your college has a computer lab where MySQL and a JDK are installed, or whether you must use your own laptop.
- Confirm your batch’s exam and holiday schedule on the official notices page so your 14-day plan avoids exam weeks.
A 14-day plan for a Java and MySQL project
If you are doing the free two-week online internship at CareerSwami, which offers a free offer letter and a free completion certificate after successful completion, you can use this schedule alongside it to keep the database project on track. It also works on its own.
| Days | Focus | Output |
|---|---|---|
| 1-2 | Install JDK, MySQL, IDE; create the database and user | Working connection from Workbench |
| 3-4 | Design and create the three tables; write the seed script with invented data | schema.sql and seed.sql in Git |
| 5-6 | JDBC connection class, insert and select with PreparedStatement | Console menu that adds a mark |
| 7-8 | Join queries: averages, toppers, below-pass list | Three report methods with hand-checked results |
| 9-10 | Transactions, input validation, error handling | Bulk load that rolls back on failure |
| 11 | Indexes and EXPLAIN on a larger generated dataset | Before and after notes |
| 12 | Backup and restore test | Verified restore into a scratch database |
| 13 | Clean up code, write README with setup steps | Someone else can run your project |
| 14 | Final review against the checklist, short demo recording | Repository ready to share |
Mistakes that break student Java and MySQL projects
- Building SQL by string concatenation. Use PreparedStatement every time a value comes from a user.
- Storing marks as text or floating point. Use DECIMAL for marks so averages and comparisons stay accurate.
- Leaving connections open. Use try-with-resources; leaked connections eventually make the app hang.
- Pushing passwords to GitHub. Use environment variables and review the repository before the first push.
- Testing only the happy path. Try a duplicate roll number, a mark above max_marks, and a missing subject.
- Using real classmates’ results. Marks are personal data; invented rows prove your logic just as well.
Presenting the project in a resume or interview
Describe the project in terms of decisions, not tools. For example: “Designed a normalised three-table MySQL schema with foreign keys and a uniqueness constraint; built JDBC data access using parameterised queries and transactions; verified query results against hand-calculated expectations; tested backup and restore.” Every phrase in that sentence should be something you can explain and demonstrate. Keep the repository public only if it contains no real data and no credentials.
Be ready for follow-up questions: why a foreign key, what an index costs, what happens if two users update the same row, and how you would add a web layer. You do not need perfect answers, but you do need honest ones based on what you built.
Frequently Asked Questions
Do I need to know advanced Java before starting this project?
No. If you understand classes, methods, loops, exceptions and basic collections, you can follow this walkthrough. JDBC is a small API, and the project teaches the rest as you go.
Which MySQL version and Connector/J version should I use?
Use a current MySQL 8.x Community release and the matching current Connector/J from Maven Central. Check the official download pages for the latest versions, as numbers change.
Why not just use Hibernate or Spring Data from the start?
Frameworks hide SQL and connection handling. If you learn plain JDBC first, you will understand what the framework generates and can debug it when queries are slow or wrong.
How do I stop SQL injection in a Java application?
Use PreparedStatement with placeholders for every value, never concatenate user input into SQL, and connect with a database user that has only the privileges the app needs.
Is it safe to use my real class marks as test data?
It is better not to. Marks and enrolment details are personal data. Generate invented names and roll numbers such as T-001, which are enough to test every query.
How often should I back up a small project database?
Take a mysqldump before any schema change and at the end of each working session. A backup only counts once you have restored it into a scratch database and checked the row counts.
Will this project count for credit at my university as a Jai Prakash Vishwavidyalaya student?
Nothing verified here says it will. The Placement Cell page does not state internship rules or credits, so ask your department in writing before assuming it counts for anything.
Does the CareerSwami internship give a stipend or a job?
No. It is a free two-week online internship with a free offer letter and a free completion certificate after successful completion. It does not promise a stipend, academic credit or placement.
Related Java & Enterprise Software guides
- Patna University Students: How to Present a Java Internship Certificate and Project Together
- Sandip University Students: Exploring Spring Boot Versus Jakarta EE for Your First Internship
- Java and Enterprise Software Internship Skills for Osmania University Students: A Preparation Checklist
- All Java & Enterprise Software internship guides
Ready to put this into practice?
Join the free two-week CareerSwami online internship in Java & Enterprise Software. The internship, the offer letter and the completion certificate are free.














