[英]Disable button not calling java method correctly?
我在调用我的java方法时遇到了一些麻烦。 所以,我在jsf的前端有按钮。 在哪里,我叫我的java方法禁用2因素,我也有sql过程。 如果一切正常,任何人都可以检查我的java方法和sql语句。 谢谢
这是我的代码:(java方法)
public void disableTwoFactor() throws SQLException {
CallableStatement ps = null;
Connection conn = null;
ResultSet result = null;
getConfirmationCode();
if (confirmationCodeFromUser.equals(Integer.toString(confirmationCodeFromServer))) {
try {
//get database connection
conn = DataUtility.getDataSource().getConnection();
ps = conn.prepareCall(strDisableTwoFactor);
ps.clearParameters();
ps.setInt(1, this.id);
ps.setString(2, this.number);
ps.setString(3, this.passwordConfirmationStatus);
ps.registerOutParameter(4, OracleTypes.CURSOR);
ps.executeQuery();
getPassStatus(conn);
result = (ResultSet) ps.getObject(4);
result.next();
if (result.getString(1).equals("YES")) {
if (displayPassSignupPage == true) {
FacesContext.getCurrentInstance().addMessage("codeVerify",
new FacesMessage("You are now two-factor free"));
} else {
FacesContext.getCurrentInstance().addMessage("codeVerify",
new FacesMessage("You are now two-factor free"));
}
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (ps != null) {
ps.close();
}
if (conn != null) {
conn.close();
}
ps = null;
conn = null;
}
}
}
SQL语句
private static final String strDisableTwoFactor = "{call BEAN.DD_DISABLE_TWO_FACTOR(?,?,?,?,?,?)}";
我认为在您的Java代码中,您想通过procedure
更新数据库记录
因此将ps.executeQuery()
更改为ps.executeUpdate()
因为ps.executeQuery()
仅用于查询!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.