Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

For every school important task for administration department is to

manage student information


details in a procedure-oriented manner with latest updates for every
year, which need to be
available for easy access. This can be provided by a simple Students
information system to help
administration so to efficiently manage student's details.
Project Modules:
Admin Panel: The admin will have control over whole application. Admin
will be able to Add,
Delete, Update and see Students report.
User login: Students will be able to login into the system, update his
information and see some
reports.
Search option: Admin & Student can search profiles using
different filters.
Report: Admin or Students can see some reports like all students in a
class etc.
1. Login Screen
CODE:
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/

/**
*
* @author prithvijay
*/

import java.awt.HeadlessException;
import java.sql.*;
import javax.swing.JOptionPane;
public class Login extends javax.swing.JFrame {

/**
* Creates new form Login
*/

Connection conn = null;


Statement stmt = null;
ResultSet rs = null;
public Login() {
super("Login");
initComponents();
conn = jdbcDriver.createConnection();
}

/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


username = new javax.swing.JTextField();
login = new javax.swing.JToggleButton();
password = new javax.swing.JPasswordField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(51, 43, 166));

jPanel1.setName(""); // NOI18N

username.setToolTipText("Username");
username.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
usernameActionPerformed(evt);
}
});

login.setText("Login");
login.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
loginActionPerformed(evt);
}
});

password.setToolTipText("Password");

jLabel1.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N


jLabel1.setText("Password");

jLabel2.setFont(new java.awt.Font("Georgia", 1, 36)); // NOI18N


jLabel2.setText("LOGIN");

jLabel4.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N


jLabel4.setText("Username");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 111,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 111,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE,
344, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE,
344, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, 344,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(221, 221, 221)
.addComponent(jLabel2)))
.addContainerGap(20, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 49,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(56, 56, 56)
.addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(183, 183, 183)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(36, 36, 36)
.addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, 41,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(335, 335, 335)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 585,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);

pack();
}// </editor-fold>

private void usernameActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}

private void loginActionPerformed(java.awt.event.ActionEvent evt) {

try{
stmt = conn.createStatement();
String user = username.getText();
String pass = password.getText();

String query = "SELECT * FROM LOGIN WHERE USERNAME ='"+user+"' AND


PASSWORD ='"+pass+"' ";

rs = stmt.executeQuery(query);
if(rs.next())
{
setVisible(false);
HomePage hp = new HomePage();
hp.setVisible(true);
}
else
{
if(user.equals("") && pass.equals(""))
JOptionPane.showMessageDialog(null,"Please Enter Your Details");
else if(user.equals(""))
JOptionPane.showMessageDialog(null,"Username Field cannot be Empty!");
else if(pass.equals(""))
JOptionPane.showMessageDialog(null,"Password Field cannot be Empty!");
else
JOptionPane.showMessageDialog(null,"Username or Password is Invalid");
}

}
catch(HeadlessException | SQLException e)
{
JOptionPane.showMessageDialog(null,e);
}

public static void main(String args[]) {


/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional)
">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Login().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JToggleButton login;
private javax.swing.JPasswordField password;
private javax.swing.JTextField username;
// End of variables declaration
}
OUTPUT SCREEN [LOGIN]:
2.Home Page
CODE:
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to chang
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/

/**
*
* @author jhuma
*/
public class HomePage extends javax.swing.JFrame {

/**
* Creates new form HomePage
*/
public HomePage() {
initComponents();
}

/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jLabel1 = new javax.swing.JLabel();


studentRecords = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
addStd = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
logout1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
setSize(new java.awt.Dimension(1920, 1080));

jLabel1.setFont(new java.awt.Font("Unispace", 1, 36)); // NOI18N


jLabel1.setText("STUDENT MANAGEMENT SYSTEM");

studentRecords.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
studentRecordsActionPerformed(evt);
}
});

jLabel2.setText("Show All Student Records");

addStd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addStdActionPerformed(evt);
}
});

jLabel3.setText(" Add/Update/Delete Student Record");


jLabel4.setText("Log Out");

logout1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
logout1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGrou
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 591,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(176, 176, 176))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGrou
.addContainerGap(109, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING
.addGroup(layout.createSequentialGroup()
.addComponent(studentRecords, javax.swing.GroupLayout.PREFERRED_SIZE, 1
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(37, 37, 37)
.addComponent(addStd, javax.swing.GroupLayout.PREFERRED_SIZE, 170,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(34, 34, 34))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(38, 38, 38)
.addComponent(jLabel3)
.addGap(23, 23, 23)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
.addComponent(logout1, javax.swing.GroupLayout.PREFERRED_SIZE, 172,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addComponent(jLabel4)))
.addGap(276, 276, 276))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
false)
.addComponent(studentRecords, javax.swing.GroupLayout.Alignment.TRAILING
javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(addStd, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(logout1, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addContainerGap(226, Short.MAX_VALUE))
);
pack();
}// </editor-fold>

private void studentRecordsActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
setVisible(false);
StudentRecords sR = new StudentRecords();
sR.setVisible(true);
}

private void addStdActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
setVisible(false);
AddRecord sR = new AddRecord();
sR.setVisible(true);
}

private void logout1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
setVisible(false);
Login LG = new Login();
LG.setVisible(true);

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and fe
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEV
null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEV
null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEV
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEV
null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new HomePage().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton addStd;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JButton logout1;
private javax.swing.JButton studentRecords;
// End of variables declaration
}

OUTPUT SCREEN:
3.Show All Student Records
CODE:
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to chang
license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this te
*/

/**
*
* @author jhuma
*/

import java.sql.*;
import javax.swing.JOptionPane;
import java.util.*;
import javax.swing.RowFilter;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.*;
import net.proteanit.sql.DbUtils;

public class StudentRecords extends javax.swing.JFrame {

/**
* Creates new form StudentRecords
*/
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

public StudentRecords() {
super("Student");
initComponents();
conn = jdbcDriver.createConnection();
showRecords();
myinitComponenets();

public void showRecords() {


try {
stmt = conn.createStatement();
String query = "SELECT * from STUDENT_DATA";
ResultSet res = stmt.executeQuery(query);
records.setModel(DbUtils.resultSetToTableModel(res));
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, e);
}
}

/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jMenuBar1 = new javax.swing.JMenuBar();


jMenu1 = new javax.swing.JMenu();
jMenu2 = new javax.swing.JMenu();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
search = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
records = new javax.swing.JTable();
back = new javax.swing.JButton();

jMenu1.setText("File");
jMenuBar1.add(jMenu1);

jMenu2.setText("Edit");
jMenuBar1.add(jMenu2);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Segoe UI Symbol", 2, 36)); // NOI18N


jLabel1.setText("Student Records");

jLabel2.setFont(new java.awt.Font("SimSun", 1, 24)); // NOI18N


jLabel2.setText("Search");

search.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchActionPerformed(evt);
}
});
search.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
searchKeyReleased(evt);
}
public void keyTyped(java.awt.event.KeyEvent evt) {
searchKeyTyped(evt);
}
});

records.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null}
},
new String [] {
"ID", "First Name", "Class", "Stream", "Section", "Roll No", "DOB(dd/mm/yy)", "Pa
Name", "Parent's Email", "Phone"
}

){
Class[] types = new Class [] {
java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Objec
java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class,
java.lang.Object.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
true, true, true, true, true, true, true, true, false, true
};

public Class getColumnClass(int columnIndex) {


return types [columnIndex];
}

public boolean isCellEditable(int rowIndex, int columnIndex) {


return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(records);

back.setText("Return to Home Page");


back.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGrou
.addContainerGap()
.addComponent(back)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 576,
Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 271,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(688, 688, 688))
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
.addComponent(jScrollPane1)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(search, javax.swing.GroupLayout.PREFERRED_SIZE, 500,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(back, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(39, 39, 39)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN
.addComponent(search, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 407,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(44, 44, 44))
);

pack();
}// </editor-fold>

private void searchActionPerformed(java.awt.event.ActionEvent evt) {


}

private void backActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

setVisible(false);
HomePage hp = new HomePage();
hp.setVisible(true);
}

private void searchKeyReleased(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
DefaultTableModel dt = (DefaultTableModel) records.getModel();
TableRowSorter<DefaultTableModel> dtfil = new TableRowSorter<>(dt);
dtfil.setRowFilter(RowFilter.regexFilter(search.getText()));

private void searchKeyTyped(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and fe
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/p
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(StudentRecords.class.getName()).log(java.util.logging.Lev
null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(StudentRecords.class.getName()).log(java.util.logging.Lev
null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(StudentRecords.class.getName()).log(java.util.logging.Lev
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(StudentRecords.class.getName()).log(java.util.logging.Lev
null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new StudentRecords().setVisible(true);
}
});

public void myinitComponenets() {

TableRowSorter tbs = new TableRowSorter(records.getModel());


records.setRowSorter(tbs);

// Variables declaration - do not modify


private javax.swing.JButton back;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JScrollPane jScrollPane1;
public javax.swing.JTable records;
private javax.swing.JTextField search;
// End of variables declaration
}
OUTPUT SCREEN:
4.Add/Update/Delete Records
CODE:

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to chang
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this te
*/

/**
*
* @author jhuma
*/

import java.sql.*;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;
import java.util.*;
import javax.swing.ComboBoxEditor;
import javax.swing.JComboBox;
import static oracle.sql.NUMBER.e;
public class AddRecord extends javax.swing.JFrame {

/**
* Creates new form AddRecord
*/
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
public AddRecord() {
super("Add");
initComponents();
conn = jdbcDriver.createConnection();
}

/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jLabel1 = new javax.swing.JLabel();


name = new javax.swing.JTextField();
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();
jLabel7 = new javax.swing.JLabel();
pName = new javax.swing.JTextField();
pEmail = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
phone = new javax.swing.JTextField();
stream = new javax.swing.JComboBox<>();
section = new javax.swing.JComboBox<>();
grade = new javax.swing.JComboBox<>();
addR = new javax.swing.JButton();
back1 = new javax.swing.JButton();
update = new javax.swing.JButton();
searchByID = new javax.swing.JButton();
searchBar = new javax.swing.JTextField();
oldGrade = new javax.swing.JTextField();
oldStr = new javax.swing.JTextField();
oldSec = new javax.swing.JTextField();
Dob = new com.toedter.calendar.JDateChooser();
update1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Gill Sans Ultra Bold Condensed", 1, 36)); // NOI18N


jLabel1.setText("CREATE STUDENT RECORD");

name.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nameActionPerformed(evt);
}
});

jLabel2.setText("Class");

jLabel3.setText("Name");

jLabel4.setText("Section");

jLabel5.setText("Stream");

jLabel6.setText("Parent Name");
jLabel7.setText("Date of Birth");

pName.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pNameActionPerformed(evt);
}
});

pEmail.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pEmailActionPerformed(evt);
}
});

jLabel8.setText("Phone Number");

jLabel9.setText("Parent's Email");

phone.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
phoneActionPerformed(evt);
}
});

stream.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "N/A", "SCI


stream.setSelectedIndex(-1);
stream.setToolTipText("");
stream.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
streamActionPerformed(evt);
}
});
section.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { " ", "A", "B"
section.setSelectedIndex(-1);
section.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sectionActionPerformed(evt);
}
});

grade.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { " ", "I", "II", "


grade.setSelectedIndex(-1);
grade.setToolTipText("");
grade.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
gradeActionPerformed(evt);
}
});

addR.setText("Add Record");
addR.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addRActionPerformed(evt);
}
});

back1.setText("Return to Home Page");


back1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
back1ActionPerformed(evt);
}
});
update.setText("Update Record");
update.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
updateActionPerformed(evt);
}
});

searchByID.setText("Search By ID");
searchByID.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchByIDActionPerformed(evt);
}
});

searchBar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchBarActionPerformed(evt);
}
});

oldGrade.setName("");
oldGrade.setText("N/A");
oldGrade.setEditable(false);
oldGrade.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oldGradeActionPerformed(evt);
}
});

oldStr.setText("N/A");
oldStr.setEditable(false);
oldStr.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oldStrActionPerformed(evt);
}
});

oldSec.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oldSecActionPerformed(evt);
}
});

update1.setText("Delete Record");
update1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
update1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(38, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILIN
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRA
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 10
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 109
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
.addComponent(pName, javax.swing.GroupLayout.DEFAULT_SIZE, 209,
.addComponent(Dob, javax.swing.GroupLayout.DEFAULT_SIZE, javax.sw
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignm
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE,
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignm
.addComponent(oldStr, javax.swing.GroupLayout.DEFAULT_SIZE, 209
.addComponent(oldSec, javax.swing.GroupLayout.DEFAULT_SIZE, 209
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignm
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignm
.addComponent(name, javax.swing.GroupLayout.DEFAULT_SIZE, 209
.addComponent(oldGrade))))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSeque
.addGap(56, 56, 56)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
.addComponent(pEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 209,
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
.addComponent(phone, javax.swing.GroupLayout.PREFERRED_SIZE, 209, j
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 103
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
.addComponent(grade, javax.swing.GroupLayout.Alignment.TRAILING, javax.
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(stream, javax.swing.GroupLayout.Alignment.TRAILING, javax
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(section, javax.swing.GroupLayout.Alignment.TRAILING, java
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(216, 216, 216))
.addGroup(layout.createSequentialGroup()
.addGap(0, 56, Short.MAX_VALUE)
.addComponent(addR, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.sw
.addGap(18, 18, 18)
.addComponent(update, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.s
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequ
.addGap(26, 26, 26)
.addComponent(update1, javax.swing.GroupLayout.PREFERRED_SIZE, 119, j
.addGap(451, 451, 451))
.addGroup(layout.createSequentialGroup()
.addGap(200, 200, 200)
.addComponent(searchBar, javax.swing.GroupLayout.PREFERRED_SIZE, 13
.addGap(11, 11, 11)
.addComponent(searchByID, javax.swing.GroupLayout.PREFERRED_SIZE, 1
.addGap(155, 155, 155))))))
.addGroup(layout.createSequentialGroup()
.addGap(162, 162, 162)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.sw
.addComponent(back1)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(14, 14, 14)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swi
.addComponent(back1))
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN
.addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.Gr
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.sw
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
.addComponent(oldGrade, javax.swing.GroupLayout.Alignment.TRAILING, javax.sw
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.s
.addComponent(grade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, java
.addComponent(stream, javax.swing.GroupLayout.PREFERRED_SIZE, javax.sw
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, java
.addComponent(section, javax.swing.GroupLayout.PREFERRED_SIZE, javax.s
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(oldSec, javax.swing.GroupLayout.PREFERRED_SIZE, 23, java
.addComponent(oldStr, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swin
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.sw
.addComponent(Dob, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.Gro
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.sw
.addComponent(pName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.G
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN
.addComponent(pEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.G
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.sw
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.sw
.addComponent(phone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.G
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN
.addComponent(addR)
.addComponent(update)
.addComponent(searchByID)
.addComponent(searchBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swi
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(update1))
.addContainerGap(11, Short.MAX_VALUE))
);

oldGrade.getAccessibleContext().setAccessibleName("");
pack();
}// </editor-fold>

private void nameActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

private void gradeActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

private void streamActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

private void addRActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try{
stmt = conn.createStatement();

String stName = name.getText();


String stad = grade.getSelectedItem().toString();
String sec = section.getSelectedItem().toString();
String sub = stream.getSelectedItem().toString();
java.text.SimpleDateFormat fmt = new java.text.SimpleDateFormat("dd-MM-yyyy");
String birth = fmt.format(Dob.getDate());
String parent = pName.getText();
String parentEmail = pEmail.getText();
String phoneno = phone.getText();
String query = "INSERT INTO STUDENT_DATA VALUES(seq_ID.nextval, '"+stName+"','"+s
,'"+parent+"','"+parentEmail+"' , '"+phoneno+"')";
if(stName.equals(""))
JOptionPane.showMessageDialog(null,"Please Enter Your Name");
else{
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Student Record Created!");
}
setVisible(false);
HomePage hp = new HomePage();
hp.setVisible(true);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e);
}

private void pNameActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

private void pEmailActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

}
private void phoneActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:

private void sectionActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}

private void back1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
setVisible(false);
HomePage hp = new HomePage();
hp.setVisible(true);
}

private void updateActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try{
stmt = conn.createStatement();
String stName = name.getText();
String stad = grade.getSelectedItem().toString();
String sec = section.getSelectedItem().toString();
String sub = stream.getSelectedItem().toString();
java.text.SimpleDateFormat fmt = new java.text.SimpleDateFormat("dd-MM-yyyy");
String birth = fmt.format(Dob.getDate());
String parent = pName.getText();
String parentEmail = pEmail.getText();
String phoneno = phone.getText();
String id = searchBar.getText();
String query = "UPDATE STUDENT_DATA SET NAME ='"+stName+"',CLASS
='"+stad+"',STREAM='"+sub+"',SECTION='"+sec+"',DOB='"+birth+"',PARENT_NAME='"+parent
WHERE ID ='"+id+"' ";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Student Record Updated!");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e);
}
}

private void searchByIDActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

try{
stmt = conn.createStatement();
String id = (String)searchBar.getText();
String qr = "SELECT * FROM STUDENT_DATA WHERE ID ='"+id+"'";
rs = stmt.executeQuery(qr);
if(rs.next())
{
name.setText(rs.getString("NAME"));

oldGrade.setText(rs.getString("CLASS"));
oldGrade.setEditable(false);

oldStr.setText(rs.getString("STREAM"));
oldStr.setEditable(false);
String d = rs.getString("DOB");
java.util.Date date_Birth = new SimpleDateFormat("dd-MM-yyyy").parse(d);
Dob.setDate(date_Birth);

pName.setText(rs.getString("PARENT_NAME"));
pEmail.setText(rs.getString("PARENTTEMAIL"));
phone.setText(rs.getString("PHONENO"));
}
else
JOptionPane.showMessageDialog(null,"Invalid ID");

}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e);
}

private void searchBarActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

private void oldGradeActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

private void oldStrActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}

private void oldSecActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}

private void update1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try{
stmt = conn.createStatement();
String stName = name.getText();
String id = searchBar.getText();

String query = "DELETE FROM STUDENT_DATA WHERE NAME ='"+stName+"' OR ID ='"+id


stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Student Record Deleted!");
name.setText("");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e);
}
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and fe
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/p
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalled
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(AddRecord.class.getName()).log(java.util.logging.L
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AddRecord.class.getName()).log(java.util.logging.L
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AddRecord.class.getName()).log(java.util.logging.L
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AddRecord.class.getName()).log(java.util.logging.L
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new AddRecord().setVisible(true);
}
});
}

// Variables declaration - do not modify


private com.toedter.calendar.JDateChooser Dob;
private javax.swing.JButton addR;
private javax.swing.JButton back1;
public javax.swing.JComboBox<String> grade;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
public javax.swing.JTextField name;
private javax.swing.JTextField oldGrade;
private javax.swing.JTextField oldSec;
private javax.swing.JTextField oldStr;
public javax.swing.JTextField pEmail;
public javax.swing.JTextField pName;
public javax.swing.JTextField phone;
private javax.swing.JTextField searchBar;
private javax.swing.JButton searchByID;
public javax.swing.JComboBox<String> section;
public javax.swing.JComboBox<String> stream;
private javax.swing.JButton update;
private javax.swing.JButton update1;
// End of variables declaration
}
OUTPUT SCREEN :

You might also like