我正在尝试编辑/更新已输入表单的详细信息。当我尝试自行更新地址时,它可以工作。但是,当我尝试更新多个列时,却没有。我假设以下代码存在问题,因为它适用于一个实体但不超过一个。
Update register set (address, contact) = concat('"+address+"', '"+mob+"');
这是Java代码。这是错误显示,jsp显示为空白页面
try{
String session_id =null;
HttpSession session1=request.getSession(false);
if(session1!=null){
session_id=(String)session1.getAttribute("name");
}
String name = request.getParameter("name");
String email = request.getParameter("email");
String pass = request.getParameter("password");
String address = request.getParameter("address");
String mob = request.getParameter("contact");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/alt", "root", "");
Statement stmt = con.createStatement();
stmt.execute("Update register set (address, contact) = concat('"+address+"', '"+mob+"') where uid='"+session_id+"'");
out.println("registration success");
response.sendRedirect("login.jsp");
}catch(Exception e){
}
%>
答案 0 :(得分:2)
尝试以下更新语法:
update register set
address = concat('"+address+"', '"+mob+"'),
contact = concat('"+address+"', '"+mob+"')
where uid='"+session_id+"'");