我正在创建一个JavaFX项目,该项目已连接到我的SQL Server以存储电影数据。它拥有标题类型和发行年份。我想进行搜索,这样当我键入流派(说其动作)时,只会显示动作电影。现在,我对SQL和JavaFX还是很陌生,所以如果有人愿意帮助我,我将不胜感激。
此代码不产生任何错误,它只是不执行任何操作。我已经确定要在场景生成器中设置动作。
搜索功能:
@FXML
private void searchMovies(ActionEvent event){
String SQLSearch = "SELECT * FROM Movies WHERE genre = ?";
try{
Connection conn = dbConnection.getConnection();
ResultSet rs = conn.createStatement().executeQuery(SQLSearch);
while(rs.next()){
this.mData.add(new movieData(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4)));
}
}catch(SQLException e){
e.printStackTrace();
}
this.titleColumn.setCellValueFactory(new PropertyValueFactory<movieData, String>("title"));
this.starColumn.setCellValueFactory(new PropertyValueFactory<movieData, String>("actor_actress"));
this.directorColumn.setCellValueFactory(new PropertyValueFactory<movieData, String>("genre"));
this.releaseyearColumn.setCellValueFactory(new PropertyValueFactory<movieData, String>("release_year"));
this.movietable.setItems(null);
this.movietable.setItems(this.mData);
}
}