//Dao中更改顾客信息方法
public void update(customer cus){
try {
Connection conn=DBUtil.getConnection();
String sql="update customer set
cusname=?,cuspassword=?,birthday=?,telephone=?,vip=?,jifen=? where cusno=?";
PreparedStatement prep=conn.prepareStatement(sql);
prep.setString(1, cus.getCusname());
prep.setString(2, cus.getPassword());
prep.setString(3,cus.getBirthday());
prep.setLong(4, cus.getTelephone());
prep.setString(5, cus.getVip());
prep.setDouble(6, cus.getJifen());
prep.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//servlet中更改顾客信息
public class CusUpdateServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
Integer cusno = Integer.parseInt(request.getParameter("cusno"));
String cusname=request.getParameter("cusname");
String password=request.getParameter("password");
String birthday=request.getParameter("birthday");
long telephone=Long.parseLong(request.getParameter("telephone"));
String vip=request.getParameter("vip");
double jifen=Double.parseDouble(request.getParameter("jifen"));
customer cus=new customer(cusno,cusname,password,birthday,telephone,vip,jifen);
CusDao dao= new CusDao();
dao.update(cus);
response.sendRedirect("list");
}
TomCat报错Statement parameter 7 not set