java1996 2016-11-17 08:19 采纳率: 0%
浏览 818

我想在执行注册前先查询数据表里用户名出现的次数,如果次数不为0则给提示

我想在执行注册前先查询数据表里用户名出现的次数,如果次数不为0则给提示,不执行之后的操作,但是查询次数的语句好像出错了,求大神
String sql2="select count(*) from table where column='name'";
PreparedStatement pst2=conn.prepareStatement(sql2);
if(count!=0){
session.setAttribute("errmsg2", "用户名已存在,请重新输入");
}else{
}

  • 写回答

5条回答

  • CodeCxz 2016-11-17 08:26
    关注

    String sql2="select count(*) from table where column='?'";
    PreparedStatement pst2=conn.prepareStatement(sql2);
    pst2.setString(1,name);
    if(count!=0){
    session.setAttribute("errmsg2", "用户名已存在,请重新输入");
    }else{
    }

    评论

报告相同问题?