谁帮我看看阿

sunliwen1981 2003-08-23 10:37:45
dbBean.java


package pub;
import java.sql.*;
import java.io.*;
import java.util.*;

import OP.GetSQL;

public class dbBean {

public Connection conn = null;
public Statement stmt = null;
public ResultSet rs = null;

dbBean dbb=new dbBean();
ResultSet rees=dbb.executeQuery(new GetSQL().getSQL());

public dbBean() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e) {
System.err.println("OpenDB():"+e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
try {
conn=DriverManager.getConnection("jdbc:odbc:hytom","a","");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);//execute sql

}
catch (java.sql.SQLException e) {
System.err.println("OpenDB.executeQuery():"+e.getMessage());
}


finally
{
destroy();
}
return rs; }

public void destroy() {
try {
stmt.close();
conn.close();
}
catch(Exception e) {
System.err.println("DBOperate.destroy():"+e.getMessage());
}
}
}



-----------------------------
GetSQL.java


package OP;

import java.sql.*;
import java.util.*;



public class GetSQL {



GetSQL gs = new GetSQL();

private String orderID, proID, customer, Sale_Quant, handler, totals,
order_time, order_type;
public void setOrderID(String s) {
orderID = new String(s.toString());
}

public void setProID(String s) {
proID = new String(s.toString());
}

public void setCustomer(String s) {
customer = new String(s.toString());
}

public void setSale_Quant(String s) {
Sale_Quant = new String(s.toString());
}

public void setHandler(String s) {
handler = new String(s.toString());
}

public void setTotals(String s) {
totals = new String(s.toString());
}

public void setOrder_time(String s) {
order_time = new String(s.toString());
}

public void setOrder_type(String s) {
order_type = new String(s.toString());
}

String names[] = {
"orderID", "proID", "customer", "Sale_Quant", "handler", "totals",
"order_time", "order_type"};
String values[] = {
orderID, proID, customer, Sale_Quant, handler, totals, order_time,
order_type};
String sql;
int j = 0;
public String getSQL() {

for (int i = 0; i < values.length + 1; i++) {
if (values[i] != null) {
sql = "select * from HY_ORDER_TABLE where '" + names[i] + "'='" +
values[i] + "'";
j = i;

}
break;
}
for (int i = j; i < values.length + 1; i++) {
if (values[i] != null) {
sql = "select * from HY_ORDER_TABLE where '" + names[i] + "'='" +
values[i] + "'";

}
}

return sql;

}

}

-----------------------
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查询</title>
</head>

<body>

<form method="POST" action="t.jsp"><p>主键<input type="text" name="orderId" size="20">

<p>产品ID<input type="text" name="proId" size="20">

<p>客户厂家名称<input type="text" name="customer" size="20">

<p>出货数量<input type="text" name="Sale_Quant" size="20">

<p>经手人姓名<input type="text" name="handler" size="20">

<p>总货款数<input type="text" name="totals" size="20">

<p>下单时间<input type="text" name="order_time" size="20">

<p>审批类型<input type="text" name="order_type" size="20">

<p><input type="submit" value="提交" name="B1"><input type="reset" value="重置" name="B2"></p>
</form>

</body>

</html>

还差一个 jsp 文件 调用。我不会写

谁帮我看看,谢谢了


...全文
65 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangry 2003-08-24
  • 打赏
  • 举报
回复
太长了 而且在这里显示出来的格式很乱


实在是看不下去 :(
sunliwen1981 2003-08-24
  • 打赏
  • 举报
回复
谁帮我看看阿
sunliwen1981 2003-08-23
  • 打赏
  • 举报
回复
我只写 查询 的部分

而且 现在的还没有弄出来,更别说struts了
cui_yihao 2003-08-23
  • 打赏
  • 举报
回复
你的dbBean写的不太好,也不全。最好重写一下。这个页面提交到一个actionServlet中,再判断是insert、update还是select操作,调用dbBean执行,成功再转向别的页面,失败转向错误页面。

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧