Advertisement
Guest User

Untitled

a guest
Jan 11th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. @FXML
  2. private void DeleteButtonAction(ActionEvent event) throws IOException {
  3. //alterar conection!
  4. String myDriver = "org.gjt.mm.mysql.Driver";
  5. String myUrl = "jdbc:mysql://localhost/test";
  6. Class.forName(myDriver);
  7. Connection conn = DriverManager.getConnection(myUrl, "root", "");
  8.  
  9. //alterar table name
  10. String SQL = "DELETE FROM department WHERE dept_no = ? ";
  11. PreparedStatement pstmt = null;
  12.  
  13. // get a connection and then in your try catch for executing your delete...
  14.  
  15. pstmt = con.prepareStatement(SQL);
  16. pstmt.setString(1, Integer.parseInt(textfield.getText()));
  17. pstmt.executeUpdate();
  18.  
  19. conn.close();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement