Student Management System Project In Java With Source Code
The Student Management System Project In Java is developed using Java Programming Language, Student Management System Project In Java, And MySQL using NetBeans is a simple and basic level small project for learning purposes.
Also, you can modify this system as per your requirements and develop a perfect advanced-level project.
A Student Management System Java Code allows you to keep the student records and manage them when needed. This is a simple Java project with a good and interactive-looking GUI.
This Project uses MySQL Database for managing all the data stored in the database.
By the way, I have here a list of Best Java Projects With Source Code For Beginners Free Download maybe this can help a lot.
This system project also includes a downloadable Project With Source Code for free, just find the downloadable source code below and click to start downloading.
Project Information
Project Name: | Student Management System |
Language/s Used: | JAVA |
Database: | MySQL |
Type: | Desktop Application |
Developer: | IT SOURCECODE |
Updates: | 0 |
Student Management System Project In Java Features
- Add Student Information – In this feature, the user can add the information of the students.
- Update Student Information – In this feature, the user can update the information of the students inside the database.
- Delete Student Information – With this feature, the user can delete any information of the students inside the database.
- Generate Student Information – In this feature, the user can generate the report or the record of the students inside the database.
To start creating this system project, make sure that you have NetBeans IDE or any platform of Java installed on your computer.
Student Management System Project In Java With Source Code: Steps on how to create the project
Time needed: 5 minutes
These are the steps on how to create the system project.
- Step 1: Create a project.
First, open the file and then click “project” to create.
- Step 2: Create a project name.
Second, name your project.
- Step 3: Create JFrame.
Third, create a “JFrame” form.
- Step 4: Create a JFrame name.
Fourth, name your JFrame form.
- Step 5: Project Design.
Fifth, The actual design of the project.
Complete Source Code
package StudentDBMysql;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Vector;
/**
*
* @author paul.oamen
*/
public class StudentDBMysql extends javax.swing.JFrame {
private static final String username="root";
private static final String password="";
private static final String dataConn ="jdbc:mysql://localhost:3306/studentdata";
Connection sqlConn =null;
PreparedStatement pst = null;
ResultSet rs=null;
int q, i, id, deleteItem;
/**
* Creates new form StudentDBMysql
*/
public StudentDBMysql() {
initComponents();
updateDB();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//===============================Function Declaration======================================
public void updateDB()
{
//int q, i;
try
{
Class.forName("com.mysql.jdbc.Driver");
sqlConn = DriverManager.getConnection(dataConn,username,password);
pst = sqlConn.prepareStatement("select * from studentdata");
rs =pst.executeQuery();
ResultSetMetaData StData = rs.getMetaData();
q = StData.getColumnCount();
DefaultTableModel RecordTable = (DefaultTableModel)jTable1.getModel();
RecordTable.setRowCount(0);
while(rs.next()){
Vector columnData = new Vector();
for (i = 1; i <= q; i++)
{
columnData.add(rs.getString("id"));
columnData.add(rs.getString("studentid"));
columnData.add(rs.getString("firstname"));
columnData.add(rs.getString("surname"));
columnData.add(rs.getString("address"));
columnData.add(rs.getString("gender"));
columnData.add(rs.getString("mobile"));
columnData.add(rs.getString("maths"));
columnData.add(rs.getString("games"));
columnData.add(rs.getString("datasci"));
columnData.add(rs.getString("analysis"));
columnData.add(rs.getString("graphic"));
columnData.add(rs.getString("database1"));
columnData.add(rs.getString("science"));
columnData.add(rs.getString("english"));
}
RecordTable.addRow(columnData);
}
}
catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex);
}
}
//=============================================================================================
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel2 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jLabel15 = new javax.swing.JLabel();
jPanel5 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jPanel7 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
txtFirstname = new javax.swing.JTextField();
txtStudentID = new javax.swing.JTextField();
txtAddress = new javax.swing.JTextField();
txtSurname = new javax.swing.JTextField();
txtMobile = new javax.swing.JTextField();
cboGender = new javax.swing.JComboBox<>();
jPanel3 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
cboGraphic = new javax.swing.JComboBox<>();
cboDatabase = new javax.swing.JComboBox<>();
cboScience = new javax.swing.JComboBox<>();
cboEnglish = new javax.swing.JComboBox<>();
jPanel8 = new javax.swing.JPanel();
jLabel11 = new javax.swing.JLabel();
cboMaths = new javax.swing.JComboBox<>();
cboGames = new javax.swing.JComboBox<>();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
cboAnalysis = new javax.swing.JComboBox<>();
cboDataSci = new javax.swing.JComboBox<>();
jPanel6 = new javax.swing.JPanel();
btnPrint = new javax.swing.JButton();
btnUpdate = new javax.swing.JButton();
btnReset = new javax.swing.JButton();
btnDelete = new javax.swing.JButton();
btnExit = new javax.swing.JButton();
btnAddNew = new javax.swing.JButton();
jPanel9 = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(95, 158, 160), 4));
jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel4.setBackground(new java.awt.Color(0, 153, 255));
jPanel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel4.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel15.setBackground(new java.awt.Color(0, 153, 255));
jLabel15.setFont(new java.awt.Font("Tahoma", 1, 60)); // NOI18N
jLabel15.setText("Student Management Systems Using Java");
jLabel15.setToolTipText("");
jPanel4.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, -1));
jPanel2.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 1340, 90));
jPanel5.setBackground(new java.awt.Color(0, 153, 255));
jPanel5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel5.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(95, 158, 160), 4));
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"ID", "Student ID", "Firstname", "Surname", "Address", "Gender", "Mobile", "Maths", "Games", "Data Sci", "Analysis", "Graphic", "Database", "Science", "English"
}
) {
Class[] types = new Class [] {
java.lang.Object.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTable1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jTable1);
jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 870, 380));
jPanel5.add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 10, 890, 410));
jPanel7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(95, 158, 160), 4));
jPanel7.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel1.setText("Mobile");
jPanel7.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 180, -1, -1));
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel2.setText("Student ID");
jPanel7.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, -1, -1));
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel3.setText("Firstname");
jPanel7.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, -1, -1));
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel4.setText("Surname");
jPanel7.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 110, -1, -1));
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel5.setText("Address");
jPanel7.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, -1, -1));
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel6.setText("Gender");
jPanel7.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, -1, -1));
txtFirstname.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jPanel7.add(txtFirstname, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 60, 300, -1));
txtStudentID.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jPanel7.add(txtStudentID, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 20, 300, -1));
txtAddress.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jPanel7.add(txtAddress, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 140, 300, -1));
txtSurname.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jPanel7.add(txtSurname, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 100, 300, -1));
txtMobile.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jPanel7.add(txtMobile, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 180, 100, -1));
cboGender.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
cboGender.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "", "Female", "Male", "" }));
jPanel7.add(cboGender, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 180, 120, -1));
jPanel3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel3.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel7.setText("Graphic");
jPanel3.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel8.setText("Database");
jPanel3.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, -1, -1));
jLabel9.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel9.setText("Science");
jPanel3.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, -1, -1));
jLabel10.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel10.setText("English");
jPanel3.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 130, -1, -1));
cboGraphic.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
cboGraphic.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "No", "Yes", "Core Unit", "Complete" }));
jPanel3.add(cboGraphic, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 10, 90, 30));
cboDatabase.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
cboDatabase.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "No", "Yes", "Core Unit", "Complete" }));
jPanel3.add(cboDatabase, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 50, 90, 30));
cboScience.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
cboScience.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "No", "Yes", "Core Unit", "Complete" }));
jPanel3.add(cboScience, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 90, 90, 30));
cboEnglish.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
cboEnglish.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "No", "Yes", "Core Unit", "Complete" }));
jPanel3.add(cboEnglish, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 130, 90, 30));
jPanel7.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 220, 200, 170));
jPanel8.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel8.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
jPanel8.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel11.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel11.setText("Maths");
jPanel8.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, -1, -1));
cboMaths.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
cboMaths.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "No", "Yes", "Core Unit", "Complete" }));
jPanel8.add(cboMaths, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 10, 90, 30));
cboGames.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
cboGames.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "No", "Yes", "Core Unit", "Complete" }));
jPanel8.add(cboGames, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 50, 90, 30));
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel12.setText("Games");
jPanel8.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, -1, -1));
jLabel13.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel13.setText("Data Sci");
jPanel8.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, -1, -1));
jLabel14.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel14.setText("Analysis");
jPanel8.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, -1, -1));
cboAnalysis.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
cboAnalysis.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "No", "Yes", "Core Unit", "Complete" }));
jPanel8.add(cboAnalysis, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 130, 90, 30));
cboDataSci.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
cboDataSci.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "No", "Yes", "Core Unit", "Complete" }));
jPanel8.add(cboDataSci, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 90, 90, 30));
jPanel7.add(jPanel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 220, 200, 170));
jPanel5.add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 420, 410));
jPanel6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(95, 158, 160), 4));
jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
btnPrint.setBackground(new java.awt.Color(0, 153, 255));
btnPrint.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
btnPrint.setText("Print");
btnPrint.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPrintActionPerformed(evt);
}
});
jPanel6.add(btnPrint, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 10, 212, 60));
btnUpdate.setBackground(new java.awt.Color(0, 153, 255));
btnUpdate.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
btnUpdate.setText("Update");
btnUpdate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnUpdateActionPerformed(evt);
}
});
jPanel6.add(btnUpdate, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 10, 212, 60));
btnReset.setBackground(new java.awt.Color(0, 153, 255));
btnReset.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
btnReset.setText("Reset");
btnReset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnResetActionPerformed(evt);
}
});
jPanel6.add(btnReset, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 10, 212, 60));
btnDelete.setBackground(new java.awt.Color(0, 153, 255));
btnDelete.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
btnDelete.setText("Delete");
btnDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDeleteActionPerformed(evt);
}
});
jPanel6.add(btnDelete, new org.netbeans.lib.awtextra.AbsoluteConstraints(880, 10, 212, 60));
btnExit.setBackground(new java.awt.Color(0, 153, 255));
btnExit.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
btnExit.setText("Exit");
btnExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnExitActionPerformed(evt);
}
});
jPanel6.add(btnExit, new org.netbeans.lib.awtextra.AbsoluteConstraints(1100, 10, 212, 60));
btnAddNew.setBackground(new java.awt.Color(0, 153, 255));
btnAddNew.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
btnAddNew.setText("Add New");
btnAddNew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddNewActionPerformed(evt);
}
});
jPanel6.add(btnAddNew, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 10, 200, 60));
jPanel5.add(jPanel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 430, 1320, 80));
jPanel2.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, 1340, 520));
getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 1360, 640));
javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
jPanel9.setLayout(jPanel9Layout);
jPanel9Layout.setHorizontalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 770, Short.MAX_VALUE)
);
jPanel9Layout.setVerticalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
getContentPane().add(jPanel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 690, 770, -1));
pack();
setLocationRelativeTo(null);
}// </editor-fold>
private void btnResetActionPerformed(java.awt.event.ActionEvent evt) {
txtStudentID.setText("");
txtFirstname.setText("");
txtSurname.setText("");
txtAddress.setText("");
cboGender.setSelectedIndex(0);
txtMobile.setText("");
cboMaths.setSelectedIndex(0);
cboGames.setSelectedIndex(0);
cboDataSci.setSelectedIndex(0);
cboAnalysis.setSelectedIndex(0);
cboGraphic.setSelectedIndex(0);
cboDatabase.setSelectedIndex(0);
cboScience.setSelectedIndex(0);
cboEnglish.setSelectedIndex(0);
DefaultTableModel RecordTable = (DefaultTableModel) jTable1.getModel();
RecordTable.setRowCount(0);
}
private JFrame frame;
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
frame = new JFrame("Exit");
if (JOptionPane.showConfirmDialog(frame, "Confirm if you want to exit","Student Management Systems",
JOptionPane.YES_NO_OPTION)==JOptionPane.YES_NO_OPTION){
System.exit(0);
}
}
private void btnAddNewActionPerformed(java.awt.event.ActionEvent evt) {
try
{
Class.forName("com.mysql.jdbc.Driver");
sqlConn = DriverManager.getConnection(dataConn,username,password);
pst = sqlConn.prepareStatement("insert into studentdata(studentid,firstname,surname,address,"
+ "gender,mobile,maths,games,datasci,analysis,graphic,database1,science,english)values"
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pst.setString(1, txtStudentID.getText());
pst.setString(2, txtFirstname.getText());
pst.setString(3, txtSurname.getText());
pst.setString(4, txtAddress.getText());
pst.setString(5, (String) cboGender.getSelectedItem());
pst.setString(6, txtMobile.getText());
pst.setString(7, (String)cboMaths.getSelectedItem());
pst.setString(8, (String)cboGames.getSelectedItem());
pst.setString(9, (String)cboDataSci.getSelectedItem());
pst.setString(10, (String)cboAnalysis.getSelectedItem());
pst.setString(11, (String)cboGraphic.getSelectedItem());
pst.setString(12, (String)cboDatabase.getSelectedItem());
pst.setString(13, (String)cboScience.getSelectedItem());
pst.setString(14, (String)cboEnglish.getSelectedItem());
pst.executeUpdate();
JOptionPane.showMessageDialog(this,"Student Record Added");
updateDB();
}
catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(StudentDBMysql.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (SQLException ex) {
//System.err.println(ex);
java.util.logging.Logger.getLogger(StudentDBMysql.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
}
private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel RecordTable = (DefaultTableModel)jTable1.getModel();
int SelectedRows = jTable1.getSelectedRow();
try
{
//int id
id = Integer.parseInt(RecordTable.getValueAt(SelectedRows, 0).toString());
Class.forName("com.mysql.jdbc.Driver");
sqlConn = DriverManager.getConnection(dataConn,username,password);
pst = sqlConn.prepareStatement("update studentdata set studentid =?,firstname=?,surname=?,"
+ "address=?,gender=?,mobile=?,maths=?,games=?,datasci=?,analysis=?,graphic=?,"
+ "database1=?,science=?,english=? where id =?");
pst.setString(1, txtStudentID.getText());
pst.setString(2, txtFirstname.getText());
pst.setString(3, txtSurname.getText());
pst.setString(4, txtAddress.getText());
pst.setString(5, (String) cboGender.getSelectedItem());
pst.setString(6, txtMobile.getText());
pst.setString(7, (String)cboMaths.getSelectedItem());
pst.setString(8, (String)cboGames.getSelectedItem());
pst.setString(9, (String)cboDataSci.getSelectedItem());
pst.setString(10, (String)cboAnalysis.getSelectedItem());
pst.setString(11, (String)cboGraphic.getSelectedItem());
pst.setString(12, (String)cboDatabase.getSelectedItem());
pst.setString(13, (String)cboScience.getSelectedItem());
pst.setString(14, (String)cboEnglish.getSelectedItem());
pst.setInt(15, id);
pst.executeUpdate();
JOptionPane.showMessageDialog(this,"Student Record updated");
updateDB();
}
catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(StudentDBMysql.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (SQLException ex) {
System.err.println(ex);
}
}
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
DefaultTableModel RecordTable = (DefaultTableModel)jTable1.getModel();
int SelectedRows = jTable1.getSelectedRow();
txtStudentID.setText(RecordTable.getValueAt(SelectedRows, 1).toString());
txtFirstname.setText(RecordTable.getValueAt(SelectedRows, 2).toString());
txtSurname.setText(RecordTable.getValueAt(SelectedRows, 3).toString());
txtAddress.setText(RecordTable.getValueAt(SelectedRows, 4).toString());
cboGender.setSelectedItem(RecordTable.getValueAt(SelectedRows, 5).toString());
txtMobile.setText(RecordTable.getValueAt(SelectedRows, 6).toString());
cboMaths.setSelectedItem(RecordTable.getValueAt(SelectedRows, 7).toString());
cboGames.setSelectedItem(RecordTable.getValueAt(SelectedRows, 8).toString());
cboDataSci.setSelectedItem(RecordTable.getValueAt(SelectedRows, 9).toString());
cboAnalysis.setSelectedItem(RecordTable.getValueAt(SelectedRows, 10).toString());
cboGraphic.setSelectedItem(RecordTable.getValueAt(SelectedRows, 11).toString());
cboDatabase.setSelectedItem(RecordTable.getValueAt(SelectedRows, 12).toString());
cboScience.setSelectedItem(RecordTable.getValueAt(SelectedRows, 13).toString());
cboEnglish.setSelectedItem(RecordTable.getValueAt(SelectedRows, 14).toString());
}
private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {
MessageFormat header = new MessageFormat("Printing in progress");
MessageFormat footer = new MessageFormat("Page {0, number, integer}");
try
{
jTable1.print(JTable.PrintMode.NORMAL,header,footer);
}
catch(java.awt.print.PrinterException e)
{
System.err.format("No Printer found", e.getMessage());
}
}
private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
DefaultTableModel RecordTable = (DefaultTableModel)jTable1.getModel();
int SelectedRows = jTable1.getSelectedRow();
try
{
//int id
id = Integer.parseInt(RecordTable.getValueAt(SelectedRows, 0).toString());
//int deleteItem
deleteItem = JOptionPane.showConfirmDialog(null,"Confirm if you want to delete item",
"Warning",JOptionPane.YES_NO_OPTION);
if (deleteItem ==JOptionPane.YES_OPTION )
{
Class.forName("com.mysql.jdbc.Driver");
sqlConn = DriverManager.getConnection(dataConn,username,password);
pst = sqlConn.prepareStatement("delete from studentdata where id =?");
pst.setInt(1, id);
pst.executeUpdate();
JOptionPane.showMessageDialog(this,"Student Record updated");
updateDB();
txtStudentID.setText("");
txtStudentID.requestFocus();
txtFirstname.setText("");
txtSurname.setText("");
txtAddress.setText("");
cboGender.setSelectedIndex(0);
txtMobile.setText("");
cboMaths.setSelectedIndex(0);
cboGames.setSelectedIndex(0);
cboDataSci.setSelectedIndex(0);
cboAnalysis.setSelectedIndex(0);
cboGraphic.setSelectedIndex(0);
cboDatabase.setSelectedIndex(0);
cboScience.setSelectedIndex(0);
cboEnglish.setSelectedIndex(0);
}
}
catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(StudentDBMysql.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (SQLException ex) {
System.err.println(ex);
}
}
Downloadable Source Code Below
Admin
Username: Admin
Password: pass
Summary
The Student Management System Project In Java is built fully in Java, using Netbeans, and MySQL Database. It has a full-featured Graphical User Interface (GUI) with all the functionalities.
This Article is a way to enhance and develop our skills and logic ideas which is important in practicing the Java programming language which is the most well-known and most usable programming language in many companies.
Related article below
- Load data from MySQL database to Combo box Using Java
- How to use Scanner in Java Tutorial Using Netbeans IDE
- Update Data using MySQL Database and Java with Netbeans IDE
- Join Two String Value using MySQL CONCAT Function in Java
- How to convert text to speech in Java Tutorial using Netbeans IDE
Inquiries
If you have any questions or suggestions about the Student Management System Project In Java With Source Code, please feel free to leave a comment below.
Can you please give how to create MySQL database for this project?
If you have then please send me also
Hello sir how to setup this project can you tell me about it?