Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().equalsIgnoreCase("Save")) {
- try {
- Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
- Connection con = DriverManager.getConnection("jdbc:ucanaccess://E:\IDM Downloads\Compressed\student managemtnt system\StudentManagementSystem\student.accdb");
- try {
- String str = "insert into student(RollNo,SName,Phno,Sex,FName,Occupation,"
- + "MName,Dob,Age,Caste,Religion,Hname,City,District,State,pin,Year,Qualification)"
- + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- PreparedStatement ps = con.prepareStatement(str);
- ps.setString(1, txtAdNo.getText());
- ps.setString(2, txtName.getText());
- ps.setString(3, txtPhNo.getText());
- ps.setString(4, cmbSex.getSelectedItem().toString());
- ps.setString(5, txtFatherName.getText());
- ps.setString(6, txtOccupation.getText());
- ps.setString(7, txtMotherName.getText());
- ps.setString(8, txtDOB.getText());
- ps.setString(9, txtAge.getText());
- ps.setString(10, txtCaste.getText());
- ps.setString(11, txtReligion.getText());
- ps.setString(12, txtHouseName.getText());
- ps.setString(13, txtCity.getText());
- ps.setString(14, txtDistrict.getText());
- ps.setString(15, txtState.getText());
- ps.setString(16, txtPin.getText());
- ps.setString(17, txtYear.getText());
- ps.setString(18, txtQualification.getText());
- ps.executeUpdate();
- JOptionPane.showMessageDialog(null, "Registration details successfully updated", "Success", JOptionPane.INFORMATION_MESSAGE);
- ClearForm();
- }
- catch (Exception x) {
- JOptionPane.showMessageDialog(null, "Error on database operation,Updation failure", "Error", JOptionPane.ERROR_MESSAGE);
- }//inner try catch closed
- } catch (Exception ex) {
- JOptionPane.showMessageDialog(null, "Error on connection to database, cannot continue updation process", "Error", JOptionPane.ERROR_MESSAGE);
- }//outer try catch closed
- }//if closed
- if (e.getActionCommand().equalsIgnoreCase("Clear")) {
- ClearForm();
- }//if closed
- if (e.getActionCommand().equalsIgnoreCase("Cancel")) {
- this.dispose();
- }//if closed
- }
Add Comment
Please, Sign In to add comment