我可以将getText()与null进行比较吗

时间:2018-07-22 16:38:36

标签: java mysql database javafx null

@FXML private TextField currentAdd;
@FXML private TextField newAdd;
@FXML private TextField currentMail;
@FXML private TextField newMail;

@FXML
public void editDetails(ActionEvent event){
    try {
            if (currentAdd.getText().equals("") || newAdd.getText().equals("")) {
                String qr = "update customer set c_mail='" + newMail.getText() + "' where c_mail='" + currentMail.getText() + "'";
                rs = st.executeQuery(qr);
            }  else {
                String qr = "update customer set c_address='" + newAdd.getText() + "',c_mail='" + newMail.getText() + "' where c_mail='" + currentMail.getText() + "'";
                rs = st.executeQuery(qr);
            }
    }
    catch (Exception e) {
        System.out.println(e);
    }

我从中得到空异常。我想看看TextField是否为空,如果它为空,我想写我的if条件以将数据发送到数据库

0 个答案:

没有答案