当前位置: 编程技术>java/j2ee
jsp与sql语句的混合使用示例
来源: 互联网 发布时间:2014-10-20
本文导语: 话不多说,直接上例子 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"); de...
话不多说,直接上例子
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
与delete,insert差不多
select
[code]
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
代码如下:
与delete,insert差不多
select
[code]