<%--
Document : DeleteData
Created on : 4 Mar, 2021, 8:12:52 PM
Author : KANHA
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.lang.*" %>
<%@page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Delete Data From Database</title>
</head>
<body>
<h1>Delete Data From Database</h1>
<% try
{
//load the driver
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
Statement st=con.createStatement();
String q="delete from user where id=4";
int i =st.executeUpdate(q);
if(i>0){
out.println("Deleted Successfully");
}
else{
out.println("Sorry No Data Found");
}
}
catch(Exception e)
{
out.println(e);
}
%>
</body>
</html>
0 Comments