update1
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="update2.jsp"method="post">
<br><br><br><br><br><br><br><br><br><br>
<div align="center">请输入学号:<input type="text" name="id"></div><br>
<div align="center"><input type="submit" value="查找"></div>
</form>
</body>
</html>
update2
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%! int id; %>
<%! int id1; %>
<%! String name; %>
<%! double weight;%>
<%! String tel; %>
<%
id=Integer.parseInt(request.getParameter("id"));
String drivername="com.mysql.jdbc.Driver";
String user="root";
String usepwd="test";
String dbname="sys";
String url1="jdbc:mysql://localhost:3306/"+dbname;
String url2="?user="+user+"&password="+usepwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(drivername);
Connection conn=DriverManager.getConnection(url);
String sql="select * from java where id=?";
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setInt(1,id);
ResultSet rs=pstmt.executeQuery();
if(rs.next()){
id1=rs.getInt("id");
name=rs.getString("name");
weight=rs.getDouble("weight");
tel=rs.getString("tel");
}
%>
<form action="update3.jsp"method="post">
<br><br><br><br><br><br><br><br><br><br>
<div align="center">
学号:<input type="text" name="id" value=<%=id1%>><br>
姓名:<input type="text" name="name" value=<%=name%>><br>
体重:<input type="text" name="weight" value=<%=weight%>><br>
电话:<input type="text" name="tel" value=<%=tel%>><br>
<input type="submit" value="提交">
</div>
</form>
</body>
</html>
update3
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%! int id; %>
<%! int id1; %>
<%! String name; %>
<%! double weight;%>
<%! String tel; %>
<%
String drivername="com.mysql.jdbc.Driver";
String user="root";
String usepwd="test";
String dbname="sys";
String url1="jdbc:mysql://localhost:3306/"+dbname;
String url2="?user="+user+"&password="+usepwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(drivername);
Connection conn=DriverManager.getConnection(url);
String sql="update java set weight=?,tel=? where id=?";
id=Integer.parseInt(request.getParameter("id"));
name=request.getParameter("name");
weight=Double.parseDouble(request.getParameter("weight"));
tel=request.getParameter("tel");
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, weight);
pstmt.setString(2,tel);
pstmt.setInt(3, id);
int n=pstmt.executeUpdate();
if(n>=1)out.print("数据更改成功"+"<br>");
else out.print("数据更改失败");
%>
</body>
</html>