Guest User

Msrks insert button

a guest
Jan 9th, 2018
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.70 KB | None | 0 0
  1. private void insertBtnActionPerformed(java.awt.event.ActionEvent evt)
  2.  {                                          
  3.         if((insertadmntf.getText()).equals(""))
  4.               JOptionPane.showMessageDialog(null,"Invalid Entry!");
  5.         else if((insertexamnameTF.getText()).equals(""))
  6.               JOptionPane.showMessageDialog(null,"Invalid Entry!");
  7.         else{
  8.               try{
  9.                      int admn=Integer.parseInt(updateadmntf.getText());
  10.                     String examname=examnameTF.getText();
  11.                     if((mathstf.getText()).equals(“”)
  12.                                 String maths=null;
  13.                     else
  14.                                 int maths=Integer.parseInt(mathstf.getText());
  15.                     if((physicstf.getText()).equals(“”)
  16.                                 String physics=null;
  17.                     else
  18.                                 int physics=Integer.parseInt(physicstf.getText());
  19.                     if((chemistrytf.getText()).equals(“”)
  20.                                 String chemistry=null;
  21.                     else
  22.                                 int chemistry=Integer.parseInt(chemistrytf.getText());
  23.                     if((iptf.getText()).equals(“”)
  24.                                 String ip=null;
  25.                     else
  26.                                 int ipInteger.parseInt(iptf.getText());
  27.                     if((englishtf.getText()).equals(“”)
  28.                                 String english=null;
  29.                     else
  30.                                 int english=Integer.parseInt(englishtf.getText());
  31.                     if((biologytf.getText()).equals(“”)
  32.                                 String biology=null;
  33.                     else
  34.                                 int biology=Integer.parseInt(biologytf.getText());
  35.                     if((psychologytf.getText()).equals(“”)
  36.                                 String psychology=null;
  37.                     else
  38.                                 int psychology=Integer.parseInt(psychologytf.getText());
  39.                     if((accountancytf.getText()).equals(“”)
  40.                                 String accountancy=null;
  41.                     else
  42.                                 int accountancy=Integer.parseInt(accountancytf.getText());
  43.                     if((businesstf.getText()).equals(“”)
  44.                                 String business=null;
  45.                     else
  46.                                 int business=Integer.parseInt(businesstf.getText());
  47.                     if((economicstf.getText()).equals(“”)
  48.                                 String economics=null;
  49.                     else
  50.                                 int economics=Integer.parseInt(economicstf.getText());
  51.                    Class.forName("java.sql.Driver");
  52.                    Connection con=DriverManager.getConnection
  53.                                           ("jdbc:mysql://localhost/eschool","root","1234");
  54.                    Statement stmt=con.createStatement();
  55.                    String query="insert into results values("+admn+",'"+examname+"',”+maths+”,”+english+”,”+physics+”,”+chemistry+”,”+biology+”,”+ip+”,\”+accountancy+”,”+economics+”,”+psychology+”,”+business+”);";
  56.                    stmt.executeUpdate(query);
  57.                    JoptionPane.showMessageDialog(null,"Marks inserted!");
  58.                    stmt.close();
  59.                    con.close();
  60.                   }
  61.                 catch(Exception e)
  62.                   {
  63.                           JoptionPane.showMessageDialog(null,"Server Down.Try again later");
  64.                     }
  65.         }
  66. }
Add Comment
Please, Sign In to add comment