Advertisement
Guest User

Untitled

a guest
Feb 8th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. private void AddbtActionPerformed(java.awt.event.ActionEvent evt) {
  2. String id = idFld.getText() ;
  3. String item = ADDfld.getText();
  4. String amount = AMOUNTfld.getText();
  5. try {
  6.  
  7. con=DriverManager.getConnection("jdbc:mysql://localhost:3306/isdb","root","");
  8.  
  9. String query = "Insert into item (id,NAME,AMOUNT) values (?,?,?)";
  10.  
  11. pst = con.prepareStatement(query);
  12.  
  13. pst.setInt(1, Integer.parseInt(id));
  14. pst.setString(2, item);
  15. pst.setString(3,amount);
  16. pst.execute();
  17.  
  18. } catch (SQLException ex ) {
  19.  
  20. JOptionPane.showMessageDialog(null, ex);
  21.  
  22. }
  23.  
  24. ADDfld.setText("");
  25. idFld.setText("");
  26. AMOUNTfld.setText("");
  27. updateCombo();
  28. update_Table();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement