Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @FXML
- public void updateEmpleat(ActionEvent event) throws ParseException, NumberFormatException, ClassNotFoundException, SQLException, IOException{
- Class.forName("org.postgresql.Driver");
- String url = "jdbc:postgresql:sun.in";
- Connection conn = DriverManager.getConnection(url, "postgres", "postgres");
- long idV = Long.parseLong(id.getText());
- String nomV = nom.getText();
- String cog1V = cog1.getText();
- String cog2V = cog2.getText();
- float souV = Float.parseFloat(sou.getText());
- DateFormat dateformat = new SimpleDateFormat("dd-MM-yyyy");
- java.util.Date date;
- String dataconV = datacon.getText();
- date = dateformat.parse(dataconV);
- String telfV = telf.getText();
- String adrecaV = adreca.getText();
- String carregV = carreg.getText();
- BooleanProperty b = admin.selectedProperty();
- Boolean adminV = b.getValue();
- String sql = "UPDATE empleat SET nom = ? , cognoms1 = ?, cognoms2 = ?, sou= ?, data_contract = ? , telefon = ?, adreça = ?, administrador = ? , carrec = ? " +"WHERE id_empleat = ?";
- PreparedStatement pst = conn.prepareStatement(sql);
- pst.setString(1, nomV);
- pst.setString(2, cog1V);
- pst.setString(3, cog2V);
- pst.setDouble(4, souV);
- pst.setDate(5, new java.sql.Date(date.getTime()));
- pst.setString(6, telfV);
- pst.setString(7, adrecaV);
- pst.setBoolean(8, adminV);
- pst.setString(9, carregV);
- pst.setLong(10, idV);
- pst.executeUpdate();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement