java student information system program jdbc odbc
import javax.swing.*;import java.awt.event.*;
import java.sql.*;
import java.awt.*;
public class StudInformation extends JFrame implements ActionListener
{
JTextField txt_id,txt_name,txt_age,txt_course,txt_semester,txt_tutor;
JLabel lbl_title,lbl_id,lbl_name,lbl_age,lbl_course,lbl_semester,lbl_tutor;
JButton btn_insert,btn_delete,btn_update,btn_clear,btn_search;
Connection c;
public StudInformation()
{
lbl_title=new JLabel("Student Information");
lbl_id=new JLabel("Id");
lbl_name=new JLabel("Name");
lbl_age=new JLabel("Age");
lbl_course=new JLabel("Course");
lbl_semester=new JLabel("Semester");
lbl_tutor=new JLabel("Tutor");
txt_id=new JTextField(20);
txt_name=new JTextField(20);
txt_age=new JTextField(20);
txt_course=new JTextField(20);
txt_semester=new JTextField(20);
txt_tutor=new JTextField(20);
btn_insert=new JButton("Insert");
btn_delete=new JButton("Delete");
btn_update=new JButton("Update");
btn_clear=new JButton("Clear");
btn_search=new JButton("Search");
btn_insert.addActionListener(this);
btn_delete.addActionListener(this);
btn_update.addActionListener(this);
btn_clear.addActionListener(this);
btn_search.addActionListener(this);
JPanel p1,p2,p3;
p1=new JPanel();
p1.setLayout(new FlowLayout());
p1.add(lbl_title);
p2=new JPanel();
p2.setLayout(new GridLayout(6,2));
p2.add(lbl_id);
p2.add(txt_id);
p2.add(lbl_name);
p2.add(txt_name);
p2.add(lbl_age);
p2.add(txt_age);
p2.add(lbl_course);
p2.add(txt_course);
p2.add(lbl_semester);
p2.add(txt_semester);
p2.add(lbl_tutor);
p2.add(txt_tutor);
p3=new JPanel();
p3.setLayout(new FlowLayout());
p3.add(btn_insert);
p3.add(btn_delete);
p3.add(btn_update);
p3.add(btn_clear);
p3.add(btn_search);
Container c=getContentPane();
c.setLayout(null);
p1.setBounds(20,20,300,40);
p2.setBounds(10,80,200,320);
p3.setBounds(10,400,300,80);
c.add(p1);
c.add(p2);
c.add(p3);
}
public void actionPerformed(ActionEvent ae)
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=DriverManager.getConnection("jdbc:odbc:stud");
}
catch(Exception ex)
{
}
String btn=ae.getActionCommand();
if(btn.equals("Clear"))
{
txt_id.setText("");
txt_name.setText("");
txt_age.setText("");
txt_course.setText("");
txt_semester.setText("");
txt_tutor.setText("");
}
if(btn.equals("Search"))
{
String id=txt_id.getText();
try{
String query1="Select *from stud where id='"+id+"'";
Statement st=c.createStatement();
ResultSet rs=st.executeQuery(query1);
while(rs.next())
{
txt_id.setText(rs.getString("id"));
txt_name.setText(rs.getString("name"));
txt_age.setText(rs.getString("age"));
txt_course.setText(rs.getString("course"));
txt_semester.setText(rs.getString("semester"));
txt_tutor.setText(rs.getString("tutor"));
}
}
catch(Exception ex)
{
}
}
if(btn.equals("Update"))
{
String s1=txt_id.getText();
String s2=txt_name.getText();
String s3=txt_age.getText();
String s4=txt_course.getText();
String s5=txt_semester.getText();
String s6=txt_tutor.getText();
try{
PreparedStatement ps=c.prepareStatement("Update stud set id=?,name=?,age=?,course=?,semester=?,tutor=? where id=?");
ps.setString(1,s1);
ps.setString(2,s2);
ps.setString(3,s3);
ps.setString(4,s4);
ps.setString(5,s5);
ps.setString(6,s6);
ps.setString(7,s1);
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"Successfully Updated");
txt_id.setText("");
txt_name.setText("");
txt_age.setText("");
txt_course.setText("");
txt_semester.setText("");
txt_tutor.setText("");
}
catch(Exception ex)
{
}
}
if(btn.equals("Delete"))
{
String s1=txt_id.getText();
try{
PreparedStatement ps=c.prepareStatement("Delete *from stud where id=?");
ps.setString(1,s1);
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"Successfully deleted");
txt_id.setText("");
txt_name.setText("");
txt_age.setText("");
txt_course.setText("");
txt_semester.setText("");
txt_tutor.setText("");
}
catch(Exception ex)
{
}
}
if(btn.equals("Insert"))
{
String s1=txt_id.getText();
String s2=txt_name.getText();
String s3=txt_age.getText();
String s4=txt_course.getText();
String s5=txt_semester.getText();
String s6=txt_tutor.getText();
try{
PreparedStatement ps=c.prepareStatement("insert into stud values(?,?,?,?,?,?)");
ps.setString(1,s1);
ps.setString(2,s2);
ps.setString(3,s3);
ps.setString(4,s4);
ps.setString(5,s5);
ps.setString(6,s6);
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"Successfully Inserted");
txt_id.setText("");
txt_name.setText("");
txt_age.setText("");
txt_course.setText("");
txt_semester.setText("");
txt_tutor.setText("");
}
catch(Exception ex)
{
}
}
}
public static void main(String args[])
{
StudInformation stud=new StudInformation();
stud.setVisible(true);
stud.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
stud.setSize(new Dimension(400,520));
}
}
output
studnt information system java |
Student management system is a software application for education establishments to manage student data. MyClassboard.com Fully Online School Management System is a database application that runs on a server, which is the center of your student information system.
ReplyDeleteStudent Information System is a very big application, the module you have developed is a small part of it. I am not in approach to dis-heartened you, I am just encouraging you to get the interest to design the remaining modules; it is really a very good start you have taken. Now you need to complete it, also you look on the user interface side you have to do a good front end designing.
ReplyDeleteThank you for giving the code. I was searching this code only as I want to develop a software to maintain the record of the school.
ReplyDeleteOnline Student Information System By Bocavox