qr=ss.createQuery("update Adddata set std_name='" +
request.getParameter("std_name") + "',std_sex='" +
request.getParameter("std_sex")+ "',std_mob='" +
request.getParameter("std_mob")+ "',std_email='" +
request.getParameter("std_email")+ "',std_course='" +
request.getParameter("std_course")+ "',std_add='" +
request.getParameter("std_add")+ "',std_fname='" +
request.getParameter("std_fname")+ "',std_date='" +
request.getParameter("std_date")+"'
where stid ='"+request.getParameter("std_id")+"'");
答案 0 :(得分:0)
Mysql默认日期格式为yyyy-mm-dd
。
请检查您的request.getParameter("std_date")
值日期格式。
例如:日期:2017-10-20
更新HQL查询
Query query = session.createQuery("update Adddata set std_name= :stdname" +
" ,std_sex = :stdsex "+
... //do the same for other values
" ,std_date = :stddate"
" where stid = :stdid");
query.setParameter("stdname", request.getParameter("std_name"));
query.setParameter("stdsex", request.getParameter("std_sex"));
... //do the same for other values
设置日期值
query.setDate("stddate", request.getParameter("std_date"));
或者如果你考虑时间也是
query.setTimestamp("stddate", dateObj)
query.setParameter("stdid", request.getParameter("std_id"));
int result = query.executeUpdate();