Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TableColumn<datadetail, String> id =
- new TableColumn<datadetail, String>("Id");
- TableColumn<datadetail, String> email =
- new TableColumn<datadetail, String>("Email");
- TableColumn<datadetail, Date> datum =
- new TableColumn<datadetail, Date>("Datum");
- email.setCellValueFactory(new PropertyValueFactory<>("email"));
- email.setCellFactory(TextFieldTableCell.<datadetail> forTableColumn());
- email.setOnEditCommit((CellEditEvent<datadetail, String> event) -> {
- TablePosition<datadetail, String> pos = event.getTablePosition();
- String newEmail = event.getNewValue();
- int row = pos.getRow();
- datadetail datadetail = event.getTableView().getItems().get(row);
- datadetail.setEmail(newEmail);
- });
- public void setEmail(String email) {
- this.id = id;
- this.email = email;
- try {
- Class.forName("com.mysql.cj.jdbc.Driver");
- Connection con = DriverManager.getConnection(
- "jdbc:mysql://localhost/java","root","123456");
- // System.out.println("Connect success!");
- PreparedStatement pstm = con.prepareStatement("update test set email = ? where id = ?");
- pstm.setString(1, email);
- pstm.setInt(2, id);
- int editemail = pstm.executeUpdate();
- pstm.executeUpdate();
- System.out.println("Updated " + editemail + " records");
- } catch (ClassNotFoundException ex) {
- System.out.println("ClassNotFoundException");
- System.out.println("Error message: " + ex);
- } catch (SQLException ex) {
- System.out.println("SQLException");
- System.out.println("Error message: " + ex);
- }
- }
- public void setDatum(Date datum) {
- this.id = id;
- this.datum = datum;
- try {
- Class.forName("com.mysql.cj.jdbc.Driver");
- Connection con = DriverManager.getConnection(
- "jdbc:mysql://localhost/java","root","123456");
- // System.out.println("Connect success!");
- PreparedStatement pstm = con.prepareStatement("update test set datum = ? where id = ?");
- pstm.setString(1, datum);
- pstm.setInt(2, id);
- int editdatum = pstm.executeUpdate();
- pstm.executeUpdate();
- System.out.println("Updated " + editdatum + " records");
- } catch (ClassNotFoundException ex) {
- System.out.println("ClassNotFoundException");
- System.out.println("Error message: " + ex);
- } catch (SQLException ex) {
- System.out.println("SQLException");
- System.out.println("Error message: " + ex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement