select * from usertable where usercode='username' and activeflag=y
其中username是从页面中取值的变量

解决方案 »

  1.   

    比如jsp页面中查询前要写个字符型变量吧
    str="";
    ResultSet rs=stmt.executeQuery(str);
    怎么把select * from usertable where usercode='username' and activeflag=y赋给str?
      

  2.   

    str = "select * from usertable where usercode='username' " + activeflag=y;
    activeflag=y 这有点问题。
      

  3.   

    activeflag是数据库表中一个字段,语句本身是没问题的,就是不知道怎么加单引号和双引号
    str = "select * from usertable where usercode='username' " + activeflag=y
    最后边不加"?
      

  4.   

    String str="select * from usertable where usercode='"+username+"' and activeflag=y"
    我试了好几次都不行
      

  5.   

    String str="select * from usertable where usercode='"+username+"' and activeflag='y'";
    ResultSet rs=stmt.executeQuery(str);
     activeflag=y 是sql变量还是其它?
      

  6.   

    俺来教你。
    首先坐好
    比如这一句
    String sql=="select * from usertable where usercode='"+username+"' and activeflag=y"
    out.println(sql);去掉左右两边的双引号放到数据中去查一下就知道对错了一般username是数据库中的字段是字符串类型,y是整形
      

  7.   

    out.println(sql);打印出来是
    select * from usertable where usercode='123' and activeflag=y