如何在javafx中为文本字段设置值

时间:2018-09-17 08:17:24

标签: java javafx javafx-8 javafx-2

如何为sql数据库中的文本字段存储设置值,如何从数据库中设置UserName数据存储以在javafx的textfield中设置并存储在textFied中

public class UpdateStaffController implements Initializable {

    @FXML
    private static JFXTextField UIUpdateStaffUsername ;
    public TextField UIUpdateStaffFirstName;
    public TextField UIUpdateStaffLastName;
    public ComboBox UIUpdateStaffGender;
    public TextField UIUpdateStaffMobile;
    public TextField UIUpdateStaffQualification;
    public TextField UIUpdateStaffAadharCard;
    public TextField UIUpdateStaffDOB;
    public TextField UIUpdateStaffDOJ;
    public TextField UIUpdateStaffEamil;
    public ComboBox UIUpdateStaffDesignation;
    public ComboBox UIUpdateStaffDepartment;
    public TextField UIUpdateStaffAddress;
    public Button btnUpdateStaff;
    public Label Errormessage;
    public Button btnUpdateDelete;
    public String  id, SetUsername;
    ObservableList<UpdateStaffModel> UpdateStaffList = FXCollections.observableArrayList();
    public void getName(Object name){
        try {
            String Sql = "select * from Staff where FirstName='"+name+"' ;";
            ResultSet rs = Objects.requireNonNull(DBUtils.INSTANCE.databaseStatement()).executeQuery(Sql);
            while (rs.next()) {
                id=rs.getString("id");
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            String Sql = "select * from Staff where id ='"+id+"' ;";
            ResultSet rs = Objects.requireNonNull(DBUtils.INSTANCE.databaseStatement()).executeQuery(Sql);
            while (rs.next()) {
                UpdateStaffList.add(new UpdateStaffModel(rs.getString("UserName"), rs.getString("FirstName"),rs.getString("LastName"),rs.getString("Mobile"),rs.getString("Email"),rs.getString("Designation"),rs.getString("IsActive")));

            }

        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
    @Override
    public void initialize(URL location, ResourceBundle resources) {
    }

如何从数据库设置UserName数据存储以在javafx的textfield中设置并存储在textFied中

0 个答案:

没有答案