日期:2014-05-17 浏览次数:20679 次
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ page import="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<body>
<%
request.setCharacterEncoding("GBK");
String Tname = request.getParameter("Tname");
Connection conn = null;
Statement stat = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/mldn";
String user = "root";
String password = "root";
conn = DriverManager.getConnection(url,user,password);
stat = conn.createStatement();
stat.executeUpdate("delete from textinfo where Tname = " + Tname + "");
rs = stat.executeQuery("select * from textinfo");
if(rs.next())
{
out.print("<center><br><br><h3>删除成功!</h3></center>");
}
else{
out.print("<center><h3>删除失败!</h3></center>");
}
%>
<br>
<br>
<center> <a href=addStuInfo.jsp>返回添加信息页面</a> <a href=showInfo.jsp>返回信息查询页面</a></center>
<%
if(rs != null)
{
rs.close();
rs = null;
}
if(stat != null)
{
stat.close();
stat = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
%>
</body>
</html>
<a href="delete.jsp?Tname=<%=rs.getString("Tname") %>">删除</a>