日期:2014-05-16  浏览次数:20353 次

jsp与sql语句的混合使用

话不多说,直接上例子

insert

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

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

deleteinsert差不多

 

select

<%

while (rs.next()){ 

            String