Words not much to say, directly on the example
Insert
Copy Code code as follows:
String sql= "INSERT into allorder values (' + orderid +" ', ' + BookID + "', ' + Amount +" ', ' "+ Username +") ";
int result=stmt.executeupdate (SQL);
if (result==1)
Response.sendredirect ("index.jsp");
Else
Response.sendredirect ("detail.jsp");
Delete
Copy Code code as follows:
String condition= "Delete from Allorder where id= '" + orderid+ "'";
int result=stmt.executeupdate (condition);
if (result==1)
Response.sendredirect ("index.jsp");
Else
Out.println ("shopcar.jsp");
Update
Copy Code code as follows:
Same as Delete,insert.
Select
[Code]
<%
while (Rs.next ()) {
String amount=rs.getstring ("Amount");
String orderid=rs.getstring ("id");
String bookname=rs.getstring ("name");
String price=rs.getstring ("price");
String picture=rs.getstring ("pic");
Out.println ("\tshuliang" +amount);
%>
<tr><td><%=orderid%></td><td><%=picture%></td><td><%= BookName%></td><td><%=price%></td><td><%=amount%></td><td> <table><tr><td><input type= "button" value= "delete" onclick= "window.location.href= ' delete.jsp"? Orderid=<%=orderid%> ' "></td></tr></table></td></tr>
<%
}
Close connection
Stmt.close ();//Close Command object connection
Con.close ()//Close database connection
catch (SQLException e) {
E.printstacktrace ();
OUT.PRINTLN ("Database connection error");
System.exit (0);
}
Database connection Complete
%>
</table>