📄 deleteuser2.jsp
字号:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%//接收要删除的用户ID号
long user_id;
try
{
user_id=Long.parseLong(request.getParameter("user_id"));
}
catch(Exception e)
{
user_id=0;
}
%>
<%//构造追加记录SQL语句
String sqlString=null;//SQL语句
if(user_id!=0)//接收到的参数正确
{
sqlString="delete from userTable where user_id="+user_id;
//执行SQL语句
try
{ Connection con;
Statement sql;
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=testDatabse","sa","");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
sql.executeUpdate(sqlString);
con.close();
}
catch(SQLException e1)
{
out.print("SQL异常!");
}
}
%>
<head>
<title>用户注册程序</title>
</head>
<body>
<center>
<table border="1" width="700">
<tr>
<td width="100%" colspan="2" align="center">删除用户程序</td>
</tr>
<tr>
<td width="100%" colspan="2">删除用户成功!</td>
</tr>
</table>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -