This Domain(Admin5.com) is for Sale:

全面解析JDBC

时间:2007-10-22  来源:不详  作者:林子



图2 查询主页面 本文来自织梦

  query.htm将用户选择查询的数据库表和查询条件发送给demo_query.jsp,由jsp文件完成数据库查询操作和查询结果集的返回及显示,其功能代码如下:

copyright dedecms

<html>
<body>
<%
String sqlStatement;
String sqlField = "";
String whichTable = "";
String whereClause = "";
String queryNo = "";
String queryName = "";
%>
<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());
}
%>
<!--prepare sql statement-->
<%
String queryRequest = request.getParameter("rb_request");
//out.println("queryRequest:" queryRequest);
String whichCB = "";
if (queryRequest.equals("1")){
whichCB = "ck_jhcg";
whichTable = "jhcg_table";
queryNo = request.getParameter("ed_jhcg_no");

内容来自dedecms


queryName = request.getParameter("ed_jhcg_name");
if (!queryNo.equals(""))
whereClause = " where good_no=" "'" queryNo "'";
if (!queryName.equals("")){
if (!queryNo.equals(""))
whereClause = " and good_name=" "'" queryName "'";
else whereClause = " where good_name=" "'" queryName "'";
}
}
if (queryRequest.equals("2")){
whichCB = "ck_kctj";
whichTable = "kctj_table";
queryNo = request.getParameter("ed_kctj_no");
queryName = request.getParameter("ed_kctj_name");
if (!queryNo.equals(""))
whereClause = " where good_no=" "'" queryNo "'";
if (!queryName.equals("")){
if (!queryNo.equals(""))
whereClause = " and good_name=" "'" queryName "'";

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

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

文章评论

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