如何使用jsp从数据库中删除选定的数据?

时间:2016-12-31 07:34:23

标签: javascript jsp jsp-tags

请帮帮我..这是我在jsp中的fisrt代码,我不知道怎么做对

<body>
    <%
         String sid = request.getParameter("u_id");
         try
        {
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","M0hdZ@k1");
            PreparedStatement ps = con.prepareStatement("delete from information where id = '"+sid+ "'");
            ps.executeUpdate();
            con.close();
            ps.close();
        }
        catch(Exception ex)
         {
           out.println(ex.getMessage());
          }
    %>
    <h1>Record Deleted...</h1><br>
           <center><a href="Admin.jsp">Go Back</a></center>

0 个答案:

没有答案