这篇文章主要介绍了jsp与sql语句的混合使用,需要的朋友可以参考下
insert
+”‘,'” + amount + “‘,'” + username + “‘)”;
int result=stmt.executeUpdate(sql);
if(result==1)
response.sendRedirect(“index.jsp”);
else
response.sendRedirect(“detail.jsp”);
delete
int result=stmt.executeUpdate(condition);
if(result==1)
response.sendRedirect(“index.jsp”);
else
out.println(“shopCar.jsp”);
update
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);
%>
<input type="button" value="删除" onclick="window.location.href='delete.jsp?orderid='”> |
<%
}
// 关闭连接
stmt.close();// 关闭命令对象连接
con.close();// 关闭数据库连接
} catch (SQLException e) {
e.printStackTrace();
out.println(“数据库连接错误”);
System.exit(0);
}
//数据库连接完成
%>
以上就是jsp与sql语句的混合使用示例的详细内容,更多请关注gaodaima搞代码网其它相关文章!