Student Information Management System Using Java Swing and MySQL
This article presents a complete Java Swing‑based student information management system, detailing the MySQL database schema, JDBC CRUD operations, model classes, DAO layer, utility classes, and a Swing UI, providing a practical example for building desktop applications with database integration.
The article demonstrates how to build a student information management system with Java Swing for the user interface and MySQL as the backend database. It outlines the development environment (JDK 7, MySQL 5, Windows 7) and the overall project structure (model‑dao‑view).
Database Design : The SQL scripts create the student and admin tables, define fields such as id , name , sno , department , and set primary keys and character set.
CREATE DATABASE student; CREATE TABLE admin (id int NOT NULL AUTO_INCREMENT, name varchar(20) NOT NULL, username varchar(20) NOT NULL, password varchar(20) NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE student (id int NOT NULL AUTO_INCREMENT, name varchar(20) NOT NULL, sno varchar(20) NOT NULL, sex varchar(20) NOT NULL, department varchar(20) NOT NULL, hometown varchar(20) NOT NULL, mark varchar(20) NOT NULL, email varchar(20) NOT NULL, tel varchar(20) NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;Model Layer : Java classes Admin and Student encapsulate the table fields with getters and setters.
public class Admin { private int id; private String name; private String username; private String password; /* getters and setters */ } public class Student { private int id; private String sno; private String name; private String sex; private String department; private String homeTown; private String mark; private String email; private String tel; /* getters and setters */ }Utility Class : DBUtil wraps JDBC connection handling, providing methods executeUpdate and executeQuery with parameter binding and resource cleanup.
public class DBUtil { private Connection conn; private PreparedStatement ps; private ResultSet rs; public int executeUpdate(String sql, Object[] obj) { /* prepare, set parameters, execute */ } public ResultSet executeQuery(String sql, Object[] obj) { /* prepare, set parameters, query */ } public void close() { /* close rs, ps, conn */ } }DAO Layer : An abstract BaseDAO supplies a shared DBUtil instance and common result‑set handling. AdminDAO implements login verification, while StudentDAO provides CRUD operations, pagination, and name‑based search, using prepared statements and the utility class.
public class StudentDAO extends BaseDAO { public boolean add(Student stu) { /* insert */ } public boolean update(Student stu) { /* update */ } public boolean delete(Student stu) { /* delete */ } public String[][] queryByName(String name) { /* like query */ } public String[][] list(int pageNum) { /* pagination */ } }View Layer : Swing UI classes ( LoginView , MainView , AddView , DeleteView , UpdateView ) interact with the DAO layer. MainView displays a paginated JTable , provides navigation buttons, and a search field that triggers StudentDAO.queryByName on Enter.
public class MainView extends JFrame { /* init panels, buttons, table */ private void find() { String param = condition.getText(); String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).queryByName(param); initJTable(jTable, result); } }The article concludes with a link to the GitHub repository and a brief invitation to like or share the post.
Java Captain
Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.