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();
        }
    }



}

Good for you. Maybe you'd be willing to tell us what the problem is.

problem is this servlet not delete the record from database table

Okay? What exception do you get? Have you printed the query to make sure you are executing what you think you are executing?

You are not committing the transaction and you are not closing either the statement or the connection.

Edit: And do not cobble together statements like that unless you want sporadic SQL syntax errors as well as innocent, as well as malicious, SQL injection attacks. Use a PreparedStatement.

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.