Untuk melakukan delete tabel pada database mysql kita harus melakukan query DELETE. Berikut adalah sintaks JSP yang digunakan untuk DELETE
<%@page import="java.sql.*,java.util.*"%>
<%
String id=request.getParameter("id");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/shopping","root","");
Statement st=con.createStatement();
int i=st.executeUpdate("DELETE FROM barang WHERE id="+id);
%>
<jsp:forward page="barang.jsp"/>
<%
String id=request.getParameter("id");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/shopping","root","");
Statement st=con.createStatement();
int i=st.executeUpdate("DELETE FROM barang WHERE id="+id);
%>
<jsp:forward page="barang.jsp"/>
0 Comments
Post a Comment