Java Swing Interfaces
K A Prasanna Weerasinghe
872503110 V
IJTS JSAD 89 Batch
Screen Print 01
Submit Button Code private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/asignment10","root","1234"); Statement s = c.createStatement(); s.executeUpdate("INSERT INTO studentdetails VALUES ('"+jTextField1.getText() +"','"+jTextField2.getText() +"','"+jTextField3.getText() +"','"+jTextField4.getText() +"','"+jTextField5.getText() +"')");
} catch (Exception e) { System.out.println(e); } // TODO add your handling code here: }
Update Button Code private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/asignment10","root","1234"); Statement s = c.createStatement(); s.executeUpdate("UPDATE studentdetails SET stname= '"+jTextField2.getText()+"' , stage= '"+jTextField3.getText()+"', sttel= '"+jTextField4.getText()+"', stresult= '"+jTextField4.getText()+"' WHERE stid = '"+jTextField1.getText()+"' ");
} catch (Exception e) { System.out.println(e); }// TODO add your handling code here: }
Delete Button Code private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/asignment10","root","1234"); Statement s = c.createStatement(); s.executeUpdate("DELETE FROM