开发工具:
文件大小: 130kb
下载次数: 0
上传时间: 2012-06-25
详细说明: 货架仓库管理package real.action.dao; import java.io.PrintStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.swing.ComboBoxModel; import real.action.data.SupplierData; import real.action.sql.ConnectionFactory; public class SupplierDao { private Connection conn; private Statement statement; private PreparedStatement preparedStatement;//SQL 语句被 预编译并存储在 PreparedStatement 对象中。然后可以使用此对象多次高效地执行该语句。 private ResultSet resultSet;//结果集 public boolean addSupplier(SupplierData s)//添加供应商 { String sql = "insert into suppliers values(?,?,?,?,?,?,?,?)"; try { this.conn = ConnectionFactory.getConnection(); this.preparedStatement = this.conn.prepareStatement(sql); this.preparedStatement.setInt(1, s.getSupplierId()); this.preparedStatement.setString(2, s.getSupplierName()); this.preparedStatement.setString(3, s.getSupplierAddress()); this.preparedStatement.setString(4, s.getPostCode()); this.preparedStatement.setString(5, s.getSupplierTelephone()); this.preparedStatement.setString(6, s.getSupplierFax()); this.preparedStatement.setString(7, s.getSupplierRelationer()); this.preparedStatement.setString(8, s.getSupplierEmail()); int flag = this.preparedStatement.executeUpdate(); if (flag > 0) { return true; } } catch (Exception e) { e.printStackTrace(); } return false; } public boolean isExistSupplierData() { boolean flag = true; int row = 0; String sql = "select count(sup_id) as count from suppliers"; try { this.conn = ConnectionFactory.getConnection(); this.statement = this.conn.createStatement(); this.resultSet = this.statement.executeQuery(sql); if (this.resultSet.next()) { row = this.resultSet.getInt("count"); } if (row == 0) { return false; } } catch (Exception e) { e.printStackTrace(); } return flag; } public boolean isExistSupplierById(int number)//ID已存在 { boolean flag = false; String sql = "select sup_id from suppliers"; try { this.conn = ConnectionFactory.getConnection(); this.statement = this.conn.createStatement(); this.resultSet = this.statement.executeQuery(sql); while (this.resultSet.next()) { SupplierData supplierData = new SupplierData(); supplierData.setSupplierId(this.resultSet.getInt(1));//设置ID if (supplierData.getSupplierId() == number) {//比较ID flag = true; break; } } } catch (Exception e) { e.printStackTrace(); } return flag; } public List
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.