import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class DeleteProductServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
DBManager db=new DBManager();
Connection conn=db.getConnection();
Statement stmt=conn.createStatement();
ResultSet rs=null;
String id=request.getParameter("id");
int result= stmt.executeUpdate("DELETE FROM TBL_PRODUCTS WHERE ID = id");//=+'"+id+"'+");
//int result=stmt.executeUpdate(sql);
if(result==1)
{
out.println("Delete data sucessfully");
}
else if (result!=1)
{
out.println("Delete data unsucessful");
}
} finally {
out.close();
}
}
}
hiddenman91 0 Newbie Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
hiddenman91 0 Newbie Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
hiddenman91 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.