当前位置: 技术问答>java相关
这样的sql查询在jsp中如何写?
来源: 互联网 发布时间:2015-02-05
本文导语: 我要将userid,password作为查询条件在jsp中应该如何写,是这样吗: String Userid=request.getParameter("userid"); String Password=request.getParameter("password"); ... rs_user=state.executeQuery("select * from userInfo where user_i...
我要将userid,password作为查询条件在jsp中应该如何写,是这样吗:
String Userid=request.getParameter("userid");
String Password=request.getParameter("password");
...
rs_user=state.executeQuery("select * from userInfo where user_id=Userid and password=Password order by user_id")
我知道不对啦,我想要个正确答案
String Userid=request.getParameter("userid");
String Password=request.getParameter("password");
...
rs_user=state.executeQuery("select * from userInfo where user_id=Userid and password=Password order by user_id")
我知道不对啦,我想要个正确答案
|
rs_user=state.executeQuery("select * from userInfo where user_id = '" + Userid + "' and password = '" + Password + "' order by user_id")
|
同意樓上的寫法.
字符串兩邊要有單引號.
字符串兩邊要有單引號.
|
String sql = "select * from userInfo where user_id = "+'"' + Userid +'"'+ " and password = "+'"' + Password +'"'+ " order by user_id";
rs_user=state.executeQuery(sql);
rs_user=state.executeQuery(sql);
|
hexiaofeng(java爱好者) 写的明显不对