大家帮我看一下啊,我写了两个文件.1.jsp显示数据库中的记录并提交要删除的数据.
2.jsp是的作用是删除数据,并显示删除后的记录.
运行时tomcat 不报错.两个页面里的数据库记录都能显示.问题是删除不了.数据记录前后就没有变化.
我把两个文件传上来,大家帮我看一下吧,谢谢了....
1.jsp
---------------------------------------------------------
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*" %>
<html>
<body bgcolor=pink >
<font size=3>
<form action="160.jsp" method=post>
<p>输入删记录的学号:
<input type="text" name="number">
<p>
<input type="submit" name="b" value="提交">
<p>数据库删除前的数据记录时:
<%
int number;
Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
out.print("加载驱动失败!");
}
try{
con=DriverManager.getConnection("jdbc:odbc:chenfeng"," "," ");
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM biao1");
out.print("<table border=1>");
out.print("<tr>");
out.print("<th width=100 >学号");
out.print("<th width=100 >姓名");
out.print("<th width=50 >数学成绩");
out.print("<th width=50 >英语成绩");
out.print("<th width=50 >物理成绩");
out.print("<tr>");
while(rs.next())
{
out.print("<tr>");
out.print("<td>"+rs.getInt(1)+"</td>");
out.print("<td>"+rs.getString(2)+"</td>");
out.print("<td>"+rs.getInt(3)+"</td>");
out.print("<td>"+rs.getInt(4)+"</td>");
out.print("<td>"+rs.getInt(5)+"</td>");
out.print("</tr>");
}
out.print("</table>");
con.close();
}
catch(SQLException e1)
{
out.print(e1);
}
%>
</form>
</font>
</body>
</html>