每次我按下时,Combobox我都想从每个不同的值中刷新数据database但是我每次按下组合框时得到的是,数据会继续增加而不是刷新截图public void initialize(URL url, ResourceBundle rb) { con = new DBConnect(); con.connect(); depart(); } void init(Stage stage) { this.stage = stage; } public void depart(){ String sql = "SELECT DISTINCT b.nama_bandara FROM departure as depart " + "INNER JOIN bandara as b on b.kode_bandara = depart.kode_bandara"; try { pst = con.conn.prepareStatement(sql); con.rs = pst.executeQuery(); while(con.rs.next()){ combo.getItems().addAll(con.rs.getString(1)); } } catch (SQLException ex) { Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex); } }每次我点击,数据总是增加@FXML private void CB(ActionEvent event) { String depart = combo.getValue(); String sql = "SELECT b.kota, bb.kota, single.harga FROM single_trip as single \n" + "INNER JOIN departure as depart ON depart.kode_departure = single.kode_departure \n" + "INNER JOIN bandara as b on b.kode_bandara = depart.kode_bandara \n" + "INNER JOIN arrived as arrive on arrive.kode_arrived = single.kode_arrived \n" + "INNER JOIN bandara as bb on bb.kode_bandara = arrive.kode_bandara \n" + "WHERE b.nama_bandara = '"+depart+"'";
添加回答
举报
0/150
提交
取消
