This article mainly introduces the JSP and SQL statements mixed use, the need for friends can refer to the following
Say no more, directly on the example insert 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 Code is as follows: String condition= "Delete from Allorder where id= '" + orderid+ "'"; int result=stmt.executeu Pdate (condition); if (result==1) Response.sendredirect ("index.jsp"); else out.println ("shopcar.jsp"); update code as follows: With Delete,insert almost 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.prints Tacktrace (); out.println ("Database connection error"); system.exit (0); } //Database connection complete %> </ table>