使用条件时,每当从Oracle数据库返回值时都会出现问题

时间:2019-04-18 19:15:02

标签: javafx

我正在尝试将oracle数据库中的一些值插入JavaFX项目中的表中,没有任何条件可以返回值,但它可以正常工作,但是当我设置条件不起作用时,请帮助我。 例如 : 从票证中选择*来源=?和目的地=?
    public void showResultbetweenSDT(ActionEvent event) throws SQLException{
           String source = comboboxSource.getValue().toString();
           String destination = comboboxDestination.getValue().toString();
           String transportType = comboboxTransportType.getValue().toString();
        try {
             Connection conn = MyConnectionDB.connect();

             this.dataTicket = FXCollections.observableArrayList();
             ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM flight where source=? and destination=? ");
             ps.setString(3, source);
             ps.setString(4, destination);
             rs = ps.executeQuery();
             while(rs.next()){
                    int fi=rs.getInt("flightID");                                      
                    String fc=rs.getString("flightCompany");
                    String s=rs.getString("source");
                    String d=rs.getString("destination");
                    String fd=rs.getString("flightDepartureTime");
                    String fa=rs.getString("flightArrivalTime");
                    String fdd=rs.getString("flightDateOfDeparture");
                    int fct=rs.getInt("flightCost");
                //  this.dataTicket.add(new ticket(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getInt(8)));
                    this.dataTicket.add(new ticket(fi,fc,s,d,fd,fa,fdd,fct));

             }

            } catch (SQLException ex) {
                System.out.println("error in sql "+ex);
            }
            this.columnID.setCellValueFactory(new PropertyValueFactory<ticket, Integer>("busFlightID"));
            this.columnName.setCellValueFactory(new PropertyValueFactory<ticket, String>("busFlightcompany"));
            this.columnSource.setCellValueFactory(new PropertyValueFactory<ticket, String>("busFlightSource"));
            this.columnDestination.setCellValueFactory(new PropertyValueFactory<ticket, String>("busFlightDestination"));
            this.columnDepartureTime.setCellValueFactory(new PropertyValueFactory<ticket, String>("busFlightDepartureTime"));
            this.columnArrivalTime.setCellValueFactory(new PropertyValueFactory<ticket, String>("busFlightArrivalTime"));
            this.columnDateofDeparture.setCellValueFactory(new PropertyValueFactory<ticket, String>("busFlightDateofDeparture"));
            this.columnCost.setCellValueFactory(new PropertyValueFactory<ticket, Integer>("busFlightCost"));


            this.tableResultofFlightOrBus.setItems(null);
            this.tableResultofFlightOrBus.setItems(dataTicket);

 }

0 个答案:

没有答案