<%//接受用户ID
long id;
try{
id=Long.parseLong(request.getParameter("id"));
}catch (Exception e)
{
id=0;
}
%>
<%//构造删除记录SQL语句
String sqlString=null;
if(id!=0){
sqlString="delete from usertable where id="+id;
try{
Connection con;
Statement sql;
Class.forName("com.mysql.jdbc.Driver");//加载数据库驱动程序;
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp","root","7056503");
sql=con.createStatement();
sql.executeUpdate(sqlString);
con.close();
}
catch(SQLException e){
out.print("SQL异常!");
}
}
%>
long id;
try{
id=Long.parseLong(request.getParameter("id"));
}catch (Exception e)
{
id=0;
}
%>
<%//构造删除记录SQL语句
String sqlString=null;
if(id!=0){
sqlString="delete from usertable where id="+id;
try{
Connection con;
Statement sql;
Class.forName("com.mysql.jdbc.Driver");//加载数据库驱动程序;
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp","root","7056503");
sql=con.createStatement();
sql.executeUpdate(sqlString);
con.close();
}
catch(SQLException e){
out.print("SQL异常!");
}
}
%>