⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 waredb.java

📁 第1章 大学生就业求职网 第2章 网上物流平台 第3章 华奥汽车销售集团网 第4章 佳美网络购物中心 第5章 科研成果申报管理系统 第6章 安瑞奥国际商务学院招生网 第7章 在线宽带影院
💻 JAVA
字号:
package com.cargo.db;

import java.sql.ResultSet;
import java.util.Collection;
import java.sql.SQLException;
import java.util.ArrayList;
import com.cargo.model.Ware;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: MR</p>
 * @author BWM
 * @version 1.0
 */

public class Waredb extends Conn implements Keywords {
    private ResultSet rs;
    private int t;
    public Waredb() {
    }
    public int insert(Ware ware) {
        t = insert(INSERT_INTO +
                   "tb_ware(id,name,price,unit,spec,factory,leave,resume)" +
                   VALUES + "('" + ware.getId() + "','" + ware.getName() + "'," +
                   ware.getPrice() + ",'" + ware.getUnit() + "','" +
                   ware.getSpec() + "','" + ware.getFactory() + "','" +
                   ware.getLeave() + "','" + ware.getResume() + "')");
        return t;
    }

    public Collection select() {
        return this.select("");
    }

    public Collection select(String sql) {
        Collection coll = new ArrayList();
        rs = getRs(SELECT + "*" + FROM + "tb_ware" + sql);
        try {
            while (rs.next()) {
                Ware ware = new Ware();
                ware.setId(rs.getString(1));
                ware.setName(rs.getString(2));
                ware.setPrice(rs.getFloat(3));
                ware.setUnit(rs.getString(4));
                ware.setSpec(rs.getString(5));
                ware.setFactory(rs.getString(6));
                ware.setLeave(rs.getDate(7).toString());
                ware.setResume(rs.getString(8));
                coll.add(ware);
            }
        } catch (SQLException ex) {
            System.out.print(ex.getMessage());
            ex.printStackTrace();
        }
        close();
        return coll;
    }

    public int update(Ware ware) {
        t = update(UPDATE + "tb_ware" + SET + "name='" + ware.getName() +
                   "',price=" + ware.getPrice() + ",unit='" + ware.getUnit() +
                   "',spec='" + ware.getSpec() + "',factory='" +
                   ware.getFactory() + "',leave='" + ware.getLeave() +
                   "',resume='" + ware.getResume() +"'"+
                   WHERE + "id='" + ware.getId()+"'");
        return t;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -