<%@page import ="java.sql.*"%>
2 <%@ page language="java" contentType="text/html; charset=UTF-8"
3 pageEncoding="UTF-8"%>
4 <!DOCTYPE html>
5 <html>
6 <head>
7 <meta charset="UTF-8">
8 <title>修改记录页面</title>
9 </head>
10 <body>
11 <%
12 String className="com.mysql.jdbc.Driver" ;
13 String user="root" ;
14 String password="root" ;
15 String url="jdbc:mysql://localhost:3306/db_shangke" ;
16 Connection conn= DriverManager.getConnection(url, user, password);
17 request.setCharacterEncoding("utf-8" );
18 String sql="update stu_info set weight=? where name=?" ;
19 PreparedStatement pstmt= conn.prepareStatement(sql);
20 pstmt.setFloat(1, 80 );
21 pstmt.setString(2, "张三" );
22 int n= pstmt.executeUpdate();
23 if (n==1 ){
24 %>数据修改操作成功!<br><%
25 } else {
26 %>数据修改操作失败!<br><%
27 }
28 if (pstmt!= null ){
29 pstmt.close();
30 }
31 if (conn!= null ){
32 conn.close();
33 }
34 %>
35 </body>
36 </html>
更新数据库记录
标签:local etc root tle localhost 修改 character odi weight
查看更多关于更新数据库记录的详细内容...