<%@ page language="java" contentType="text/html; charset=utf-8"%> <%@ page import="java.sql.*"%> <% request.setCharacterEncoding("utf-8") ;%> <%-- <%@ page import="com.mchange.v2.c3p0.ComboPooledDataSource" %> --%> Insert title here <% Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://localhost:3306/kui"; //指向数据库table1 String username = "root"; String password = "001011"; Connection conn = null; conn = DriverManager.getConnection(url, username, password); if(conn != null){ /* Statement stmt = conn.createStatement(); */ String name=request.getParameter("name"); if(name.equals("")){ response.sendRedirect("dele.jsp"); }else{ Statement stmt = null; ResultSet rs = null; PreparedStatement pstmt = null; String sql = "delete from student where name='"+name+"' "; pstmt = conn.prepareStatement(sql); pstmt.executeUpdate(); out.print(""); out.println("

恭喜!删除成功!



"); out.println("
\r\n" + " 查看列表\r\n" + "
"); } } else{ out.print("连接失败!"); } %>