2
回答
数据库实现修改数据功能是出现列名'studentWeight'无效错误,该如何修改?
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   
<%@page import="java.sql.*"%>
<%@ page language="java" import="java.util.*" 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">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'updateStudentCheck.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
      <%   String id=new String(request.getParameter("id"));       
           byte b[]=id.getBytes("ISO-8859-1");
           id=new String(b,"UTF-8");          
                String studentName1=request.getParameter("studentName");
                byte b1[]=studentName1.getBytes("ISO-8859-1");
                studentName1=new String(b1,"UTF-8");
                String studentSex1=request.getParameter("studentSex");
                byte b2[]=studentSex1.getBytes("ISO-8859-1");
                studentSex1=new String(b2,"UTF-8");
                String studentAge1=request.getParameter("studentAge");
                byte b3[]=studentAge1.getBytes("ISO-8859-1");
                studentAge1=new String(b3,"UTF-8");
                String studentWeight1=request.getParameter("studentWeight");
                byte b4[]=studentWeight1.getBytes("ISO-8859-1");
                studentWeight1=new String(b4,"UTF-8");    
                Connection conn=null;  
                Statement stmt=null;                    
           
           Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
           String url="jdbc:sqlserver://localhost:1433;databasename=student";
           String user="stu";
           String password="stu";
           conn= DriverManager.getConnection(url,user,password);
           stmt=conn.createStatement();          
           String sql="update student set studentName='"+studentName1+"',studentSex='"+studentSex1+
           "',studentAge="+studentAge1+",studentWeight="+studentWeight1+" where studentNumber='"+id+"'";
           stmt.executeUpdate(sql);  
           
          
              
            conn.close();                 
            stmt.close();         
            
        %>
       <h3>修改完成!</h3>
  </body>
</html>

 

举报
jask
发帖于3年前 2回/329阅
顶部