Example of mixed use of JSP and SQL statements

Source: Internet
Author: User
Tags mixed stmt

  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> 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.