Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. @FXML
  2. public void updateEmpleat(ActionEvent event) throws ParseException, NumberFormatException, ClassNotFoundException, SQLException, IOException{
  3.  
  4. Class.forName("org.postgresql.Driver");
  5. String url = "jdbc:postgresql:sun.in";
  6. Connection conn = DriverManager.getConnection(url, "postgres", "postgres");
  7.  
  8. long idV = Long.parseLong(id.getText());
  9. String nomV = nom.getText();
  10. String cog1V = cog1.getText();
  11. String cog2V = cog2.getText();
  12. float souV = Float.parseFloat(sou.getText());
  13. DateFormat dateformat = new SimpleDateFormat("dd-MM-yyyy");
  14. java.util.Date date;
  15. String dataconV = datacon.getText();
  16. date = dateformat.parse(dataconV);
  17. String telfV = telf.getText();
  18. String adrecaV = adreca.getText();
  19. String carregV = carreg.getText();
  20. BooleanProperty b = admin.selectedProperty();
  21. Boolean adminV = b.getValue();
  22.  
  23. String sql = "UPDATE empleat SET nom = ? , cognoms1 = ?, cognoms2 = ?, sou= ?, data_contract = ? , telefon = ?, adreça = ?, administrador = ? , carrec = ? " +"WHERE id_empleat = ?";
  24. PreparedStatement pst = conn.prepareStatement(sql);
  25.  
  26. pst.setString(1, nomV);
  27. pst.setString(2, cog1V);
  28. pst.setString(3, cog2V);
  29. pst.setDouble(4, souV);
  30. pst.setDate(5, new java.sql.Date(date.getTime()));
  31. pst.setString(6, telfV);
  32. pst.setString(7, adrecaV);
  33. pst.setBoolean(8, adminV);
  34. pst.setString(9, carregV);
  35. pst.setLong(10, idV);
  36.  
  37.  
  38. pst.executeUpdate();
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement