Tell me, how can I display entries from the table according to the Id entered in the text box ( searchBox - fx:id text box for entering id )?
Tried to do the following way:
@FXML private void searchUser(ActionEvent event) { String sqlfiltr = ("SELECT * FROM teachers WHERE id = '"+searchBox+"'"); try{ Connection conn = dbConnection.getConnection(); this.data = FXCollections.observableArrayList(); ResultSet rs = conn.createStatement().executeQuery(sqlfiltr); while (rs.next()){ this.data.add(new TeacherData(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5))); } } catch (SQLException e){ System.err.println("Oshibka " + e); } this.idTableColumn.setCellValueFactory(new PropertyValueFactory<TeacherData, String>("ID")); this.fnamecolum.setCellValueFactory(new PropertyValueFactory<TeacherData, String>("firstname")); this.lnamecolum.setCellValueFactory(new PropertyValueFactory<TeacherData, String>("lastname")); this.emailcolum.setCellValueFactory(new PropertyValueFactory<TeacherData, String>("email")); this.coursecolum.setCellValueFactory(new PropertyValueFactory<TeacherData, String>("course")); this.teachertable.setItems(null); this.teachertable.setItems(this.data); }