Guest User

Untitled

a guest
May 3rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. private void OKbtnActionPerformed(java.awt.event.ActionEvent evt)
  2. {
  3.  
  4. try{
  5. String password = PassJP.getText();
  6. int passint = Integer.parseInt(password);
  7. conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/banking application","root","");
  8. String query = "SELECT Balance FROM user WHERE Password =" +passint;
  9.  
  10. Statement st = conn.createStatement();
  11. ResultSet rs = st.executeQuery(query);
  12. int balance = rs.getInt("Balance");
  13.  
  14. String WAmmount = WithAmmTF.getText();
  15. int WAmmountint = Integer.parseInt(WAmmount);
  16.  
  17. int newbalance = balance - WAmmountint;
  18. Statement s=conn.createStatement();
  19. s.executeUpdate("INSERT INTO `user`(Balance) VALUE ('"+newbalance+"') where Password="+ passint);
  20.  
  21. conn.close();
  22.  
  23. }
  24. catch (SQLException e) {
  25. System.err.println("Got an exception! ");
  26. System.err.println(e.getMessage());
  27. }
Add Comment
Please, Sign In to add comment