PreparedStament sql預(yù)處理對象
PreparedStament pst =null;
String sql =" SELECT `userName`,`password` FROM `news_user` WHERE `userName` = ? AND `password` = ? " ;
Object[] pars ={user.getName(),user.getPwd()};
pst = connection.prepareStatement(sql);
for(int i =0;i<pars.length;i++;){
pst.setObject(i+1,parms[i])? ? //?占位符的初始下標(biāo)為1椭住,所以為了對應(yīng)驶赏,i+1
}
int count = pst.excuteUpdate();? //執(zhí)行失敗返回-1? 成功 有多少條返回多少條
Session
session創(chuàng)建:request.getsession()
? ? ? ? ? ? ?賦值 :session.setAttribute("","")
? ? ? ? ? ? ?獲取: session.getAttribute("","")