Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void insertBtnActionPerformed(java.awt.event.ActionEvent evt)
- {
- if((insertadmntf.getText()).equals(""))
- JOptionPane.showMessageDialog(null,"Invalid Entry!");
- else if((insertexamnameTF.getText()).equals(""))
- JOptionPane.showMessageDialog(null,"Invalid Entry!");
- else{
- try{
- int admn=Integer.parseInt(updateadmntf.getText());
- String examname=examnameTF.getText();
- if((mathstf.getText()).equals(“”)
- String maths=”null”;
- else
- int maths=Integer.parseInt(mathstf.getText());
- if((physicstf.getText()).equals(“”)
- String physics=”null”;
- else
- int physics=Integer.parseInt(physicstf.getText());
- if((chemistrytf.getText()).equals(“”)
- String chemistry=”null”;
- else
- int chemistry=Integer.parseInt(chemistrytf.getText());
- if((iptf.getText()).equals(“”)
- String ip=”null”;
- else
- int ipInteger.parseInt(iptf.getText());
- if((englishtf.getText()).equals(“”)
- String english=”null”;
- else
- int english=Integer.parseInt(englishtf.getText());
- if((biologytf.getText()).equals(“”)
- String biology=”null”;
- else
- int biology=Integer.parseInt(biologytf.getText());
- if((psychologytf.getText()).equals(“”)
- String psychology=”null”;
- else
- int psychology=Integer.parseInt(psychologytf.getText());
- if((accountancytf.getText()).equals(“”)
- String accountancy=”null”;
- else
- int accountancy=Integer.parseInt(accountancytf.getText());
- if((businesstf.getText()).equals(“”)
- String business=”null”;
- else
- int business=Integer.parseInt(businesstf.getText());
- if((economicstf.getText()).equals(“”)
- String economics=”null”;
- else
- int economics=Integer.parseInt(economicstf.getText());
- Class.forName("java.sql.Driver");
- Connection con=DriverManager.getConnection
- ("jdbc:mysql://localhost/eschool","root","1234");
- Statement stmt=con.createStatement();
- String query="insert into results values("+admn+",'"+examname+"',”+maths+”,”+english+”,”+physics+”,”+chemistry+”,”+biology+”,”+ip+”,\”+accountancy+”,”+economics+”,”+psychology+”,”+business+”);";
- stmt.executeUpdate(query);
- JoptionPane.showMessageDialog(null,"Marks inserted!");
- stmt.close();
- con.close();
- }
- catch(Exception e)
- {
- JoptionPane.showMessageDialog(null,"Server Down.Try again later");
- }
- }
- }
Add Comment
Please, Sign In to add comment