This Domain(Admin5.com) is for Sale:

全面解析JDBC

时间:2007-10-22  来源:不详  作者:林子
QQ 收藏到MisterWong

  3. JSP设计

  ① 插入操作

  完成对数据库表的记录插入功能,其中计划采购表的插入主页面(insert_jhcg.htm)为:
织梦好,好织梦



图1 计划采购表插入主页面

copyright dedecms

  insert_jhcg.htm将用户输入传送给demo_insert_jhcg.jsp,完成插入操作。改jsp文件的功能代码为:
dedecms.com

<html>
<body>
<jsp:useBean id="DBConn" class="dbaccess.DBConnBean" scope="page"/>
<jsp:useBean id="DBBean" class="dbaccess.DBQueryBean" scope="page"/>
<hr>
<!--test JavaBean-->
<%
if (DBConn == null||DBBean == null){
out.println("JavaBean not found!");
return;
}
%>
<!--try db_demo connection-->
<%
try{
DBConn.Connect();
}catch(Exception e){
out.println(e.getMessage());
}
%>
<!--execute sql statement-->
<%
String insGoodno = request.getParameter("ed_jhcg_no");
String insGoodname = request.getParameter("ed_jhcg_name");
int insAmount = (Integer.valueOf(request.getParameter("ed_jhcg_amount"))).intValue();
float insPrice = (Float.valueOf(request.getParameter("ed_jhcg_price"))).floatValue();
String insGold = request.getParameter("ed_jhcg_gold");
String insUnit = request.getParameter("ed_jhcg_unit");
String insRemark = request.getParameter("ed_jhcg_remark");

织梦内容管理系统

String sqlStatement = "insert into jhcg_table(good_no,good_name,amount,
price,gold,unit,remark) values(" "'" insGoodno "'" "," "'" insGoodname "'" ",
" insAmount "," insPrice "," "'" insGold "'" "," "'" insUnit "'" "," "'"
insRemark "'" ")";
try{
DBBean.query(sqlStatement);
}catch(Exception e){
out.println(e.getMessage());
}
%>
<a href="demo_main.htm">Records inserted...Click here to return</a></p>
</body>
</html>

  ② 查询操作

  该查询主页面主要提供对三个数据库表的条件查询功能,如下图所示:

看完这篇,您有何感觉呢?

上一篇:jsp入门学习教程   下一篇:JSP漏洞大观

文章评论

共有位Admini5网友发表了评论 查看完整内容

站长之家wangzhan.dngz.net

24小时热门信息