new41.jsp

<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
	String driverName = "com.mysql.jdbc.Driver";
	String userName = "root";
	String userPwd = "mysql123";
	String dbName = "test";
	String url = "jdbc:mysql://localhost:3306/" + dbName + "?useUnicode=true&characterEncoding=utf8";
	Class.forName(driverName);
	Connection conn = DriverManager.getConnection(url,userName,userPwd);
	
	request.setCharacterEncoding("utf-8");
	String sql = "delete from stu_info where weight >= ?";
	PreparedStatement pstmt = conn.prepareStatement(sql);
	pstmt.setFloat(1, 90);
	int n = pstmt.executeUpdate();
	if(n >= 1)
	{
		out.print("数据删除成功,共删除" + n + "条记录");
	}
	else
	{
		out.print("数据删除失败!");
	}
	
	if(pstmt != null)
	{
		pstmt.close();
	}
	if(conn != null)
	{
		conn.close();
	}
	
	
%>
</body>
</html>