Friday, August 3, 2018


         JSP(Java Server Page): how to Delete Record data from database in using mysql

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Patient Delete...</title>
</head>
<body>
<%!
        Connection con; PreparedStatement st;
        String Id;
%>
<%
        Id=request.getParameter("PatientId");
        try
        {
               Class.forName("com.mysql.jdbc.Driver");
               con=DriverManager.getConnection("jdbc:mysql://
                   localhost:3306/hospital","root","root");
               String str="delete from Patient where PatientId=(?)";
               st=con.prepareStatement(str);
               st.setString(1, Id);
               int g=st.executeUpdate();
               out.print("Record Deleted....");
               con.close();
        }
        catch(Exception e)
        {
               out.print(e.toString());
        }
%>
</body>
</html>


No comments:

Post a Comment