首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁用按钮不正确调用java方法?

禁用按钮不正确调用java方法?
EN

Stack Overflow用户
提问于 2018-04-19 15:21:37
回答 1查看 93关注 0票数 0

我在调用我的java方法时遇到了麻烦。所以,我的前端有按钮。在这里,我调用我的java方法来禁用2个因素,我也有sql过程。如果一切正常,可以检查我的java方法和sql语句吗?谢谢

下面是我的代码:(java方法)

代码语言:javascript
复制
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语句

代码语言:javascript
复制
private static final String strDisableTwoFactor = "{call BEAN.DD_DISABLE_TWO_FACTOR(?,?,?,?,?,?)}";
EN

回答 1

Stack Overflow用户

发布于 2018-04-19 15:27:02

我认为在java代码中,您希望通过procedure更新数据库记录。

所以将ps.executeQuery()更改为ps.executeUpdate()

因为ps.executeQuery()只是用于查询!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49924718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档