做一次性修改多条内容

报错内容
javax.servlet.ServletException: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''?°?é??','??·',26,54' at line 1
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.ch.changel_jsp._jspService(changel_jsp.java:145)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

相关代码
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">




学号
姓名
性别
年龄
体重

<%

String id=request.getParameter("sid");
int id1=Integer.parseInt(id);
String name=request.getParameter("sname");
String name1=new String(name.getBytes("iso-8859-1"),"utf-8");
String sex=request.getParameter("sex");
String sex1=new String(sex.getBytes("iso-8859-1"),"utf-8");
String age=request.getParameter("age");
int age1=Integer.parseInt(age);
String tiz=request.getParameter("tiz");
int tiz1=Integer.parseInt(tiz);
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/student?useUnicode=true&characterEncoding=gbk";
Connection con=DriverManager.getConnection(url,"root","123456");
String s="update stuinfo set sid="+id1+",sname='"+name1+"',sex='"+sex1+"',age="+age1+",weight="+tiz1+" where sid="+id1+"";
PreparedStatement ps=con.prepareStatement(s);
ps.executeUpdate();
ps=con.prepareStatement("select * from stuinfo");
ResultSet rs= ps.executeQuery();
while(rs.next()){
%>


<%=rs.getString("sid") %>
<%=rs.getString("sname") %>
<%=rs.getString("sex") %>
<%=rs.getString("age") %>
<%=rs.getString("weight") %>
     </tr>
     <%}%>
     </table>


Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐