stmt = conn.createStatement();
        rs=stmt.executeQuery("select * from table_1"+"where s_name='"+userName+"'");
        while(rs.next()){ String name=rs.getString(1);
                          String pw=rs.getString(2);}
这段代码错哪里 能编译可运行时提示where子句有错误!
顺便说一下userName是作为参数传过来的

解决方案 »

  1.   

    rs=stmt.executeQuery("select * from table_1"+"where s_name='"+userName+"'");where前加个空格 既可
      

  2.   

     rs = stmt.executeQuery("select * from table_1  where s_name='" + userName + "'");表名 和 WHERE之间没有空格 ,直接写成这样子不就可以了,为什么还要在两者之间用 " + " ;
      

  3.   

     rs = stmt.executeQuery("select * from table_1  where s_name='" + userName + "'");改成这样子就行啦。
      

  4.   

    表名 和 WHERE之间没有空格