{"id":87228,"date":"2023-03-02T10:14:01","date_gmt":"2023-03-02T04:44:01","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=87228"},"modified":"2026-06-03T15:00:46","modified_gmt":"2026-06-03T09:30:46","slug":"java-student-management-system","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/","title":{"rendered":"Java Student Management System &#8211; A smarter way to manage your student records."},"content":{"rendered":"<p>This project aims to guide you in creating a Student Management System using Java, Java Swing, and SQLite within the Eclipse IDE. The system will be designed to store and manage student information such as IDs, contact information, E-mail, Father\u2019s Name, and addresses, etc.<\/p>\n<h3>Java Student Management System<\/h3>\n<p>The main objective of this project is to develop a Student Management System that utilizes Java, Java Swing, and SQLite. The system will allow you to store and retrieve student information such as IDs, contacts, and addresses.<\/p>\n<p>By following this project, you will gain a basic understanding of how to create a GUI using Java Swing, connect to an SQLite database, and implement the functionality for storing and retrieving data.e.<\/p>\n<h3>Prerequisites for Student Management System using Java<\/h3>\n<ul>\n<li>Basic knowledge of Java programming<\/li>\n<li>Familiarity with Java Swing for creating GUI applications<\/li>\n<li>Knowledge of databases and SQL queries.<\/li>\n<li>Understanding of JAR files and how they are used in Java projects.<\/li>\n<li>Understanding of database management and SQLite database.<\/li>\n<li>Any Java IDE (Eclipse recommended)<\/li>\n<\/ul>\n<p><em>It is recommended to use the WindowBuilder plugin in Eclipse to make GUI development easier. The WindowBuilder allows you to drag-and-drop GUI components and generates the code automatically, making it easier to create and design Java graphical user interfaces.<\/em><\/p>\n<h3>Download Java Student Management System Project<\/h3>\n<p>Please download the source code of Java Student Management System project from the following link: <a href=\"https:\/\/drive.google.com\/file\/d\/1626lEQ4emp1d6ooBISAPrDLelqXeqpis\/view?usp=drive_link\"><strong>Java Student Management System Project Code<\/strong><\/a><\/p>\n<h3>Steps to Create Student Management System using Java<\/h3>\n<p>Following are the steps for developing the Java Student Management System project:<\/p>\n<h4>Step 1: Setting Up the Project and Classes<\/h4>\n<ol>\n<li>Open Eclipse and navigate to &#8220;File&#8221; &gt; &#8220;New&#8221; &gt; &#8220;Java Project&#8221;.<\/li>\n<li>Give your project a name, for example, &#8220;Student Management System&#8221;.<\/li>\n<li>Right-click on the project and select &#8220;New&#8221; &gt; &#8220;Class&#8221;.<\/li>\n<li>Give a name to the first class, such as &#8220;StudentManagement&#8221;.<\/li>\n<li>Repeat steps 3 and 4 to create another class, &#8220;Database&#8221;.<\/li>\n<\/ol>\n<h4>Step 2: Incorporating SQLite into the Project<\/h4>\n<ol>\n<li>Go to the Project Explorer in Eclipse.<\/li>\n<li>Select the project name by right-clicking on it and choose &#8220;Properties&#8221;.<\/li>\n<li>In the Properties window, navigate to &#8220;Java Build Path&#8221; and then click the &#8220;Libraries&#8221; tab.<\/li>\n<li>Hit the &#8220;Add External JARs&#8221; button, and locate the SQLite JAR file.<\/li>\n<li>Select the JAR file and press &#8220;Open&#8221;.<\/li>\n<li>Click &#8220;OK&#8221; to close the Properties window.<\/li>\n<\/ol>\n<p>With these steps, SQLite has now been integrated into your Eclipse project.<br \/>\nNote: Before proceeding, ensure you have the SQLite JAR file downloaded and stored in a local location. If not, it can be obtained from <a href=\"https:\/\/mvnrepository.com\/artifact\/org.xerial\/sqlite-jdbc)\">MavenRepository.<\/a><\/p>\n<h4>Step 3: Implementing the Database class created in Step:1<\/h4>\n<p>Here\u2019s the complete code for the Database class<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.TechVidvan;\r\nimport java.sql.Statement;\r\nimport javax.swing.table.DefaultTableModel;\r\nimport java.sql.Connection;\r\nimport java.sql.ResultSet;\r\nimport java.sql.SQLException;\r\nimport org.sqlite.SQLiteDataSource;\r\npublic class Database {\r\n\/\/\tdeclaring connection and datasource variables\r\n  static Connection conn;\r\n  static SQLiteDataSource ds;\r\n  \r\n\/\/\tinitialize method to initialize the database with students table\r\n  public static void dbInit() {\r\n    ds = new SQLiteDataSource();\r\n    \r\n    try {\r\nds = new SQLiteDataSource();\r\nds.setUrl(\"jdbc:sqlite:StudentManagementDB.db\");\r\n} catch ( Exception e ) {\r\ne.printStackTrace();\r\nSystem.exit(0);\r\n}\r\ntry {\r\n   conn = ds.getConnection();\r\n  \r\n   Statement stmt = conn.createStatement();\r\n\/\/ \t sql query to add student table\r\n   String query = \"CREATE TABLE IF NOT EXISTS students ( \"\r\n   \t\t\t\t+ \"student_id TEXT PRIMARY KEY ,\"\r\n   \t\t\t\t+ \"student_name TEXT,\"\r\n   \t\t\t\t+ \"father_name TEXT,\"\r\n   \t\t\t\t+ \"student_dob TEXT,\"\r\n   \t\t\t\t+ \"student_gender TEXT,\"\r\n   \t\t\t\t+ \"student_contact TEXT,\"\r\n   \t\t\t\t+ \"student_email TEXT,\"\r\n   \t\t\t\t+ \"section TEXT,\"\r\n   \t\t\t\t+ \"student_address TEXT\"\r\n   \t\t\t\t+ \" );\"; \t\r\n\/\/ \t executing the query using statement variable\r\n   stmt.executeUpdate(query);\r\n   conn.close();\r\n  \r\n} catch ( SQLException e ) {\r\ne.printStackTrace();\r\nSystem.exit( 0 );\r\n}\r\n;\r\n}\r\n  \r\n\/\/\tfunction to add the student into the database\r\n  protected static void insertStudent(String id,String name,String fatherName,\r\n                   String dob,String gender,String contact,String section,String email,String address\r\n                  ) throws SQLException {\r\n    String query = \"INSERT INTO students(student_id,student_name,father_name,student_dob,student_gender,student_contact,section,student_email,student_address) \"\r\n          + \"VALUES(\"\r\n            +\"'\"+ id +\"',\"\r\n            +\"'\"+ name +\"',\"\r\n            +\"'\"+ fatherName +\"',\"\r\n            +\"'\"+ dob +\"',\"\r\n            +\"'\"+ gender +\"',\"\r\n            +\"'\"+ contact +\"',\"\r\n            +\"'\"+ section +\"',\"\r\n            +\"'\"+ email +\"',\"\r\n            +\"'\"+ address +\"');\" ;\r\n    \r\n    conn = ds.getConnection();\r\n    Statement stmt = conn.createStatement();\r\n    stmt.executeUpdate(query);\r\n    conn.close();\r\n  }\r\n\/\/\tFucntion to update the student data using the id\r\n  protected static void updateStudent(String id,String name,String fatherName,String contact,\r\n       String dob,String gender,String email, String section,String address\r\n      ) throws SQLException {\r\n      String query = \"UPDATE students \"\r\n          + \"SET \"\r\n          + \"student_name = '\"+name + \"',\"\r\n          + \"father_name = '\"+fatherName + \"',\"\r\n          + \"student_contact = '\"+contact+ \"',\"\r\n          + \"student_dob = '\"+dob+ \"',\"\r\n          + \"student_gender = '\"+gender + \"',\"\r\n          + \"student_email = '\"+email + \"',\"\r\n          + \"section = '\"+section + \"',\"\r\n          + \"student_address = '\"+address + \"'\"\r\n          \r\n          + \"WHERE \"\r\n          + \"student_id = '\"+id+\"'\";\r\n      System.out.println(query);\r\n      conn = ds.getConnection();\r\n      Statement stmt = conn.createStatement();\r\n      stmt.executeUpdate(query);\r\n      conn.close();\r\n      }\r\n  \/\/\tfunction to delete the student from the database\r\n  protected static void deleteStudent(String id) throws SQLException {\r\n    String query = \"DELETE FROM students WHERE student_id = '\"+id+\"';\";\r\n    conn = ds.getConnection();\r\n    Statement stmt = conn.createStatement();\r\n    stmt.executeUpdate(query);\r\n    conn.close();\r\n  \r\n  }\r\n  \/\/\tfunction that searches the student in the database and updates the values using tabel model\r\n  public static void searchStudents(DefaultTableModel model,String searchTerm) throws SQLException {\r\n    model.setRowCount(0);\r\n    String query = \"SELECT * FROM students WHERE student_name LIKE '%\"+searchTerm +\"%';\";\r\n    conn = ds.getConnection();\r\n    Statement stmt = conn.createStatement();\r\n    ResultSet rs = stmt.executeQuery(query);\r\n    \r\n    while(rs.next()) {\r\n      String id = rs.getString(\"student_id\");\r\n      String name = rs.getString(\"student_name\");\r\n      String fatherName = rs.getString(\"father_name\");\r\n      String dob = rs.getString(\"student_dob\");\r\n      String gender = rs.getString(\"student_gender\");\r\n      String contact = rs.getString(\"student_contact\");\r\n      String section = rs.getString(\"section\");\r\n      String email = rs.getString(\"student_email\");\r\n      String address = rs.getString(\"student_address\");\r\n      \r\n      \r\n      model.addRow(new Object[]{id,name,fatherName,dob,gender,contact,section,email,address});\r\n      \r\n    }\r\n    \r\n    conn.close();\r\n    rs.close();\r\n    \r\n  }\r\n  \/\/ function to fetch the data and add it to the model so that the jtable is updated\r\n  public static void fetchAllData(DefaultTableModel model) throws SQLException {\r\n    model.setRowCount(0);\r\n    String query = \"SELECT * FROM students ;\";\r\n    conn = ds.getConnection();\r\n    Statement stmt = conn.createStatement();\r\n    ResultSet rs = stmt.executeQuery(query);\r\n    \r\n    while(rs.next()) {\r\n      String id = rs.getString(\"student_id\");\r\n      String name = rs.getString(\"student_name\");\r\n      String fatherName = rs.getString(\"father_name\");\r\n      String dob = rs.getString(\"student_dob\");\r\n      String gender = rs.getString(\"student_gender\");\r\n      String contact = rs.getString(\"student_contact\");\r\n      String section = rs.getString(\"section\");\r\n      String email = rs.getString(\"student_email\");\r\n      String address = rs.getString(\"student_address\");\r\n      \r\n      \r\n      model.addRow(new Object[]{id,name,fatherName,dob,gender,contact,section,email,address});\r\n      \r\n    }\r\n    \r\n    conn.close();\r\n    rs.close();\r\n    \r\n  }\r\n}\r\n<\/pre>\n<ul>\n<li>The<strong> dbInit<\/strong> method creates a new SQLite database and sets its URL. It also creates a table called &#8220;students&#8221; if it doesn&#8217;t exist already. The table has 9 columns, including &#8220;student_id&#8221; as the primary key, &#8220;student_name,&#8221; &#8220;father_name,&#8221; &#8220;student_dob,&#8221; &#8220;student_gender,&#8221; &#8220;student_contact,&#8221; &#8220;student_email,&#8221; &#8220;section,&#8221; and &#8220;student_address.&#8221;<\/li>\n<li>The <strong>insertStudent<\/strong> method takes 9 parameters, which correspond to the 9 columns of the &#8220;students&#8221; table, and inserts a new record into the table using an SQL INSERT statement.<\/li>\n<li>The <strong>updateStudent<\/strong> method updates an existing record in the &#8220;students&#8221; table using an SQL UPDATE statement. It takes 9 parameters, which correspond to the columns of the &#8220;students&#8221; table, and updates the record with a matching &#8220;student_id.&#8221;<\/li>\n<li>The <strong>deleteStudent<\/strong> method deletes a record from the &#8220;students&#8221; table using an SQL DELETE statement. It takes 1 parameter, &#8220;id,&#8221; which corresponds to the &#8220;student_id&#8221; of the record to be deleted.<\/li>\n<li>The <strong>searchStudents<\/strong> method is used to search a student in the database based on the given search term and update the values in the table model.<\/li>\n<\/ul>\n<ol>\n<li>The method takes two arguments, the first one is a DefaultTableModel object named model which represents the table model and the second one is a String object named searchTerm which represents the search term entered by the user.<\/li>\n<li>The method starts by setting the row count of the model to 0 to clear any existing data in the model.<\/li>\n<li>Next, a SQL query is created which selects all the rows from the students table where the student_name column value matches with the given searchTerm. The query uses the LIKE operator with the % wildcard character to match the search term anywhere in the student_name column.<\/li>\n<li>A database connection is established using the ds object and the query is executed using a Statement object and the executeQuery method. The result of the query is stored in a ResultSet object named rs.<\/li>\n<li>The while loop iterates over the rs object and fetches the values of each column in the current row. The values are stored in local variables such as id, name, fatherName, dob, gender, contact, section, email, and address.<\/li>\n<li>The values are then added as a new row to the model using the addRow method and passing an array of objects that represent the values for each column.<\/li>\n<li>Finally, the database connection is closed and the ResultSet object is closed to release the resources.<\/li>\n<\/ol>\n<ul>\n<li>The<strong> fetchAllData<\/strong> method is used to fetch all data from the &#8220;students&#8221; table in the database and update the values in the table model. The method takes a DefaultTableModel object as an argument.<\/li>\n<\/ul>\n<ol>\n<li>The method starts by setting the row count of the table model to zero. This is done to clear any previous data in the table model.<\/li>\n<li>Next, the method defines a SQL query that selects all data from the &#8220;students&#8221; table. The method then creates a connection to the database using the ds.getConnection() method. The connection is stored in the conn variable.<\/li>\n<li>A Statement object is then created using the conn connection, and the query is executed using the executeQuery method. The result of the query is stored in a ResultSet object, which is used to loop through the rows of the result set.<\/li>\n<li>For each row in the result set, the method retrieves the values of each column in the row and stores them in local variables. The values are then added to the table model as a new row using the addRow method of the DefaultTableModel object.<\/li>\n<li>Finally, the method closes the connection and the result set and returns.<\/li>\n<\/ol>\n<h4>Step 4: Implementing the StudentManagement class created in Step:1<\/h4>\n<p>Here\u2019s the complete code for the StudentManagement class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.TechVidvan;\r\nimport java.awt.EventQueue;\r\nimport javax.swing.JFrame;\r\nimport javax.swing.JPanel;\r\nimport java.awt.Color;\r\nimport javax.swing.JLabel;\r\nimport javax.swing.JOptionPane;\r\nimport java.awt.GridLayout;\r\nimport java.awt.event.ActionEvent;\r\nimport java.awt.event.ActionListener;\r\nimport javax.swing.JTextField;\r\nimport javax.swing.SwingConstants;\r\nimport javax.swing.JTextArea;\r\nimport javax.swing.JComboBox;\r\nimport javax.swing.JButton;\r\nimport javax.swing.table.DefaultTableModel;\r\nimport javax.swing.JScrollPane;\r\nimport javax.swing.JTable;\r\npublic class StudentManagement {\r\n  private JFrame frmStduentManagementSystem;\r\n  private JTextField nameTextField;\r\n  private JTextField fatherNameTextField;\r\n  private JTextField contactTextField;\r\n  private JTextField emailTextField;\r\n  private JTextField idTextField;\r\n  private JTextField dobtextField;\r\n  private JTable table;\r\n  private JTextField sectionTextField;\r\n  private JTextField deletetextfield;\r\n  private JTextField searchTextField;\r\n  \/**\r\n   * Launch the application.\r\n   *\/\r\n  public static void main(String[] args) {\r\n    EventQueue.invokeLater(new Runnable() {\r\n      public void run() {\r\n        try {\r\n          Database.dbInit();\r\n          StudentManagement window = new StudentManagement();\r\n          window.frmStduentManagementSystem.setVisible(true);\r\n        } catch (Exception e) {\r\n          e.printStackTrace();\r\n        }\r\n      }\r\n    });\r\n  }\r\n  \/**\r\n   * Create the application.\r\n   *\/\r\n  public StudentManagement() {\r\n    initialize();\r\n  }\r\n  \/**\r\n   * Initialize the contents of the frame.\r\n   *\/\r\n  private void initialize() {\r\n\/\/\t\tCreating new frame for the components\r\n    frmStduentManagementSystem = new JFrame();\r\n    frmStduentManagementSystem.setTitle(\"Stduent Management System by TechVidvan\");\r\n    frmStduentManagementSystem.setBounds(100, 100, 1100, 600);\r\n    frmStduentManagementSystem.setResizable(false);\r\n    frmStduentManagementSystem.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n    frmStduentManagementSystem.getContentPane();\r\n\/\/\t\tcreating the table model for jtable\r\n    DefaultTableModel model = new DefaultTableModel();\r\n    model.addColumn(\"Id\");\r\n    model.addColumn(\"Name\");\r\n    model.addColumn(\"Father's Name\");\r\n    model.addColumn(\"D.O.B\");\r\n    model.addColumn(\"Gender\");\r\n    model.addColumn(\"Contact\");\r\n    model.addColumn(\"Section\");\r\n    model.addColumn(\"E-mail\");\r\n    model.addColumn(\"Address\");\r\n    \r\n\/\/\t\tAdding the UI components\r\n    JPanel inputPanel = new JPanel();\r\n    inputPanel.setBounds(0, 0, 400, 565);\r\n    inputPanel.setBackground(new Color(153, 204, 255));\r\n    GridLayout gl_inputPanel = new GridLayout(0, 2);\r\n    gl_inputPanel.setVgap(30);\r\n    inputPanel.setLayout(gl_inputPanel);\r\n    \r\n    JLabel idLabel = new JLabel(\"Student ID\");\r\n    inputPanel.add(idLabel);\r\n    \r\n    idTextField = new JTextField();\r\n    idTextField.setHorizontalAlignment(SwingConstants.LEFT);\r\n    inputPanel.add(idTextField);\r\n    \r\n    JLabel namelabel = new JLabel(\"Student Name\");\r\n    inputPanel.add(namelabel);\r\n    \r\n    nameTextField = new JTextField();\r\n    nameTextField.setToolTipText(\"\");\r\n    nameTextField.setHorizontalAlignment(SwingConstants.LEFT);\r\n    inputPanel.add(nameTextField);\r\n    \r\n    JLabel fatherNameLabel = new JLabel(\"Father's Name\");\r\n    inputPanel.add(fatherNameLabel);\r\n    \r\n    fatherNameTextField = new JTextField();\r\n    fatherNameTextField.setHorizontalAlignment(SwingConstants.LEFT);\r\n    inputPanel.add(fatherNameTextField);\r\n    \r\n    JLabel dobLabel = new JLabel(\"Date of Birth\");\r\n    inputPanel.add(dobLabel);\r\n    \r\n    dobtextField = new JTextField();\r\n    dobtextField.setHorizontalAlignment(SwingConstants.LEFT);\r\n    inputPanel.add(dobtextField);\r\n    \r\n    JLabel genderLabel = new JLabel(\"Gender\");\r\n    inputPanel.add(genderLabel);\r\n    \r\n    JComboBox&lt;String&gt; genderComboBox = new JComboBox&lt;String&gt;();\r\n    genderComboBox.setEditable(false);\r\n    genderComboBox.setMaximumRowCount(3);\r\n    genderComboBox.addItem(\"Male\");\r\n    genderComboBox.addItem(\"Female\");\r\n    genderComboBox.addItem(\"Other\");\r\n    frmStduentManagementSystem.getContentPane().setLayout(null);\r\n    inputPanel.add(genderComboBox);\r\n    \r\n    JLabel contactLabel = new JLabel(\"Contact\");\r\n    inputPanel.add(contactLabel);\r\n    \r\n    contactTextField = new JTextField();\r\n    contactTextField.setHorizontalAlignment(SwingConstants.LEFT);\r\n    inputPanel.add(contactTextField);\r\n    \r\n    JLabel emailLabel = new JLabel(\"E-mail\");\r\n    inputPanel.add(emailLabel);\r\n    \r\n    emailTextField = new JTextField();\r\n    emailTextField.setHorizontalAlignment(SwingConstants.LEFT);\r\n    inputPanel.add(emailTextField);\r\n    \r\n    JLabel sectionLabel = new JLabel(\"Section\");\r\n    inputPanel.add(sectionLabel);\r\n    \r\n    sectionTextField = new JTextField();\r\n    sectionTextField.setHorizontalAlignment(SwingConstants.LEFT);\r\n    inputPanel.add(sectionTextField);\r\n    \r\n    JLabel addressLabel = new JLabel(\"Address\");\r\n    inputPanel.add(addressLabel);\r\n    \r\n    JTextArea addressTextArea = new JTextArea();\r\n    inputPanel.add(addressTextArea);\r\n    frmStduentManagementSystem.getContentPane().add(inputPanel);\r\n    \r\n\/\/\t\tAdding the insert button action listener to insert the student on click\r\n    JButton insertButton = new JButton(\"Insert\");\r\n    inputPanel.add(insertButton);\r\n    insertButton.addActionListener(new ActionListener() {\r\n      \r\n      @Override\r\n      public void actionPerformed(ActionEvent e) {\r\n        try {\r\n          Database.insertStudent(idTextField.getText(),\r\n                     nameTextField.getText(),\r\n                     fatherNameTextField.getText(),\r\n                     dobtextField.getText(),\r\n                     genderComboBox.getSelectedItem().toString(),\r\n                     contactTextField.getText(),\r\n                     sectionTextField.getText(),\r\n                     emailTextField.getText(),\r\n                     addressTextArea.getText());\r\n          Database.fetchAllData(model);\r\n          JOptionPane.showMessageDialog(inputPanel,\"Student successfully inserted\",\"Inserted\", JOptionPane.INFORMATION_MESSAGE);\r\n          \r\n        } catch (Exception e2) {\r\n          JOptionPane.showMessageDialog(inputPanel,\"Student ID Already exists\",\"ERROR\", JOptionPane.ERROR_MESSAGE);\r\n          e2.printStackTrace();\r\n        }\r\n      }\r\n    });\r\n    \r\n\/\/\t\tAdding the update button action listener to update the student data on click\r\n    JButton updateButton = new JButton(\"Update\");\r\n    inputPanel.add(updateButton);\r\n    updateButton.addActionListener(new ActionListener() {\r\n      \r\n      @Override\r\n      public void actionPerformed(ActionEvent e) {\r\n        \/\/ TODO Auto-generated method stub\r\n        try {\r\n          Database.updateStudent(idTextField.getText(),\r\n               nameTextField.getText(),\r\n               fatherNameTextField.getText(),\r\n               dobtextField.getText(),\r\n               genderComboBox.getSelectedItem().toString(),\r\n               contactTextField.getText(),\r\n               emailTextField.getText(),\r\n               sectionTextField.getText(), addressTextArea.getText());\r\n          Database.fetchAllData(model);\r\n          JOptionPane.showMessageDialog(inputPanel,\"Student successfully Updated\",\"Updated\", JOptionPane.INFORMATION_MESSAGE);\r\n        } catch (Exception e2) {\r\n          \r\n          e2.printStackTrace();\r\n        }\r\n      }\r\n    });\r\n    \r\n    JPanel outputPanel = new JPanel();\r\n    outputPanel.setBounds(400, 0, 700, 565);\r\n    outputPanel.setBackground(new Color(51, 209, 122));\r\n    frmStduentManagementSystem.getContentPane().add(outputPanel);\r\n    \r\n    table = new JTable(model);\r\n    table.setVisible(true);\r\n    outputPanel.setLayout(null);\r\n    \r\n    \r\n    JScrollPane scrollPane = new JScrollPane(table);\r\n    scrollPane.setBounds(0, 143, 700, 421);\r\n    scrollPane.setViewportBorder(null);\r\n    outputPanel.add(scrollPane);\r\n    \r\n    JButton showAllButton = new JButton(\"Show All\");\r\n    showAllButton.setBounds(12, 106, 117, 25);\r\n    outputPanel.add(showAllButton);\r\n    \r\n\/\/\t\tAdding the delete button action listener to delete the student on click\r\n    JButton deleteButton = new JButton(\"Delete\");\r\n    deleteButton.setBounds(12, 12, 117, 25);\r\n    outputPanel.add(deleteButton);\r\n    deleteButton.addActionListener(new ActionListener() {\r\n      \r\n      @Override\r\n      public void actionPerformed(ActionEvent e) {\r\n        \/\/ TODO Auto-generated method stub\r\n        try {\r\n          Database.deleteStudent(deletetextfield.getText());\r\n          Database.fetchAllData(model);\r\n          JOptionPane.showMessageDialog(outputPanel,\"Student successfully deleted\",\"Deleted\", JOptionPane.INFORMATION_MESSAGE);\r\n        } catch (Exception e2) {\r\n          \/\/ TODO: handle exception\r\n          e2.printStackTrace();\r\n        }\r\n      }\r\n    });\r\n    \r\n    deletetextfield = new JTextField();\r\n    deletetextfield.setBounds(154, 12, 114, 25);\r\n    outputPanel.add(deletetextfield);\r\n    deletetextfield.setColumns(10);\r\n    \r\n\/\/\t\tAdding the search button action listener to search the student on click\r\n    JButton searchButton = new JButton(\"Search\");\r\n    searchButton.setBounds(12, 62, 117, 25);\r\n    outputPanel.add(searchButton);\r\n    searchButton.addActionListener(new ActionListener() {\r\n      \r\n      @Override\r\n      public void actionPerformed(ActionEvent e) {\r\n        \/\/ TODO Auto-generated method stub\r\n          try {\r\n            Database.searchStudents(model,searchTextField.getText() );\r\n            JOptionPane.showMessageDialog(outputPanel,\"NOT Found\",\"ERROR\", JOptionPane.ERROR_MESSAGE);\r\n          } catch (Exception e2) {\r\n            \/\/ TODO: handle exception\r\n          }\r\n      }\r\n    });\r\n    \r\n    searchTextField = new JTextField();\r\n    searchTextField.setColumns(10);\r\n    searchTextField.setBounds(154, 62, 114, 25);\r\n    outputPanel.add(searchTextField);\r\n    \r\n    JLabel label = new JLabel(\"&lt;- Enter ID to delete\");\r\n    label.setBounds(286, 12, 156, 25);\r\n    outputPanel.add(label);\r\n    \r\n\/\/\t\tAdding the show all button action listener to show all the students on click\r\n    JLabel label_1 = new JLabel(\"&lt;- Enter Name to Search\");\r\n    label_1.setBounds(286, 62, 177, 25);\r\n    outputPanel.add(label_1);\r\n    showAllButton.addActionListener(new ActionListener() {\r\n      \r\n      @Override\r\n      public void actionPerformed(ActionEvent e) {\r\n        \/\/ TODO Auto-generated method stub\r\n        try {\r\n          Database.fetchAllData(model);\r\n        } catch (Exception e2) {\r\n          \/\/ TODO: handle exception\r\n          e2.printStackTrace();\r\n        }\r\n      }\r\n    });\r\n    \r\n    \r\n    \r\n  }\r\n}<\/pre>\n<ul>\n<li><strong>insertButton.addActionListener:<\/strong> This is the action listener for the &#8220;Insert&#8221; button. It listens for the button click event and performs the following actions:<\/li>\n<\/ul>\n<p>i. It calls the insertStudent method of the Database class and passes the values entered by the user in the text fields and combo box as arguments.<br \/>\nii. It calls the fetchAllData method of the Database class to retrieve all the data from the database and update the JTable with the latest data.<br \/>\niii. It shows a success message dialog to the user if the student is inserted successfully.<\/p>\n<ul>\n<li><strong>updateButton.addActionListener:<\/strong> This is the action listener for the &#8220;Update&#8221; button. It listens for the button click event and performs the following actions:<\/li>\n<\/ul>\n<p>i. It calls the updateStudent method of the Database class and passes the values entered by the user in the text fields and combo box as arguments.<br \/>\nii. It calls the fetchAllData method of the Database class to retrieve all the data from the database and update the JTable with the latest data.<br \/>\niii. It shows a success message dialog to the user if the student is updated successfully.<\/p>\n<ul>\n<li><strong>deleteButton.addActionListener:<\/strong> This is the action listener for the &#8220;Delete&#8221; button. It listens for the button click event and performs the following actions:<\/li>\n<\/ul>\n<p>i. It calls the deleteStudent method of the Database class and passes the student ID entered by the user as an argument.<br \/>\nii. It calls the fetchAllData method of the Database class to retrieve all the data from the database and update the JTable with the latest data.<br \/>\niii. It shows a success message dialog to the user if the student is deleted successfully.<\/p>\n<ul>\n<li><strong>searchButton.addActionListener:<\/strong> This is the action listener for the &#8220;Search&#8221; button. It listens for the button click event and performs the following actions:<\/li>\n<\/ul>\n<p>i. It calls the searchStudents method of the Database class and passes the model of the JTable and the search string entered by the user as arguments.<br \/>\nii. It shows an error message dialog to the user if the student is not found in the database.<\/p>\n<ul>\n<li><strong>showAllButton.addActionListener:<\/strong> This is the action listener for the &#8220;Show All&#8221; button. It listens for the button click event and performs the following actions:<\/li>\n<\/ul>\n<p>i. It calls the fetchAllData method of the Database class to retrieve all the data from the database and update the JTable with the latest data<\/p>\n<h3>Java Student Management System Output<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-87248 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/student-management-system-output.webp\" alt=\"student management system output\" width=\"1103\" height=\"602\" \/><\/p>\n<h3>Summary:<\/h3>\n<p>In this project, we learned how to build a Student Management System using Java and SQlite database. We familiarized ourselves with the basics of Java and SQlite, then created a user-friendly interface using Swing components and the grid layout.<\/p>\n<p>We also used SQL queries to perform CRUD operations on the database, including inserting, updating, and retrieving student information. We also added action listeners to various buttons for operations such as insert, update, search, delete, and show all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This project aims to guide you in creating a Student Management System using Java, Java Swing, and SQLite within the Eclipse IDE. The system will be designed to store and manage student information such&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":87249,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183],"tags":[4879,4872,2755,4904,4905,4906,4907],"class_list":["post-87228","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java-basic-project","tag-java-project-for-practice","tag-java-projects","tag-java-student-management-system","tag-java-student-management-system-project","tag-student-management-system","tag-student-management-system-project"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java Student Management System - A smarter way to manage your student records. - TechVidvan<\/title>\n<meta name=\"description\" content=\"Student Management System utilizes Java, Java Swing, and SQLite. The system will allow you to store and retrieve student information\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Student Management System - A smarter way to manage your student records. - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Student Management System utilizes Java, Java Swing, and SQLite. The system will allow you to store and retrieve student information\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-02T04:44:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T09:30:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/02\/student-management-system.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Student Management System - A smarter way to manage your student records. - TechVidvan","description":"Student Management System utilizes Java, Java Swing, and SQLite. The system will allow you to store and retrieve student information","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/","og_locale":"en_US","og_type":"article","og_title":"Java Student Management System - A smarter way to manage your student records. - TechVidvan","og_description":"Student Management System utilizes Java, Java Swing, and SQLite. The system will allow you to store and retrieve student information","og_url":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2023-03-02T04:44:01+00:00","article_modified_time":"2026-06-03T09:30:46+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/02\/student-management-system.webp","type":"image\/webp"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Java Student Management System &#8211; A smarter way to manage your student records.","datePublished":"2023-03-02T04:44:01+00:00","dateModified":"2026-06-03T09:30:46+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/"},"wordCount":1524,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/02\/student-management-system.webp","keywords":["java basic project","java project for practice","java projects","java student management system","java student management system project","student management system","student management system project"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/","url":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/","name":"Java Student Management System - A smarter way to manage your student records. - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/02\/student-management-system.webp","datePublished":"2023-03-02T04:44:01+00:00","dateModified":"2026-06-03T09:30:46+00:00","description":"Student Management System utilizes Java, Java Swing, and SQLite. The system will allow you to store and retrieve student information","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/02\/student-management-system.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2023\/02\/student-management-system.webp","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/java-student-management-system\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Java Student Management System &#8211; A smarter way to manage your student records."}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/87228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=87228"}],"version-history":[{"count":2,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/87228\/revisions"}],"predecessor-version":[{"id":448016,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/87228\/revisions\/448016"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/87249"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=87228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=87228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=87228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}