This Domain(Admin5.com) is for Sale:

全面解析JDBC

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

<%@page import="Java.util.*"%>
<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());
}
%>
<!--prepare sql statement-->
<%
int amount_jhcg,amount_kctj;
Vector updateRs = new Vector();
DBBean.query("delete * from sjcg_table"); //delete all old records in sjcg_table
DBBean.query("select jhcg_table.good_no,jhcg_table.good_name,jhcg_table.amount,kctj_table.amount,jhcg_table.unit from jhcg_table left join kctj_table on kctj_table.good_no=jhcg_table.good_no");
int rows = DBBean.getRowcount();
int cols = DBBean.getColumncount(); 织梦内容管理系统
for (int i = 0;i < rows;i ){
String record[] = new String[4];
record[0] = DBBean.get(i,0);
record[1] = DBBean.get(i,1);
amount_jhcg = (Integer.valueOf(DBBean.get(i,2))).intValue();
if (DBBean.get(i,3) == null) amount_kctj = 0;
else amount_kctj = (Integer.valueOf(DBBean.get(i,3))).intValue();
record[2] = Integer.toString(amount_jhcg - amount_kctj);
record[3] = DBBean.get(i,4);
updateRs.addElement(record);
}
for (int i = 0;i < rows;i ){
String insRecord[] = (String [])updateRs.elementAt(i);
String insGoodno,insGoodname,insUnit,insAmount;
insGoodno = insRecord[0];
insGoodname = insRecord[1];
insAmount = insRecord[2];
insUnit = insRecord[3];
String sqlStatement = "insert into sjcg_table(good_no,good_name,amount,unit) values?quot; "'" insGoodno "'" "," "'" insGoodname "'" "," insAmount "," "'" insUnit "'" ")";
DBBean.query(sqlStatement);

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

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

文章评论

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